大网数据广告活动
服务器运维问答

Should I be running docker bridge0 on the same subnet as my docker host?

· 52CE 我爱测

I have decided to run some docker containers on my home net using a custom (user-defined) bridge interface. I gave the bridge a static IP on the same network as my docker host. The docker host's eth0 has: 192.168.10.20/24 while t…

问题原文

原帖链接 · mr.zog · CC BY-SA 4.0

I have decided to run some docker containers on my home net using a custom (user-defined) bridge interface. I gave the bridge a static IP on the same network as my docker host. The docker host's eth0 has: 192.168.10.20/24 while the docker bridge0 is configured for 192.168.10.21/24. I do not need to have docker containers talking to other docker containers. I want each container to run a service on its own IP address, accessible to any host on my 192.168.10.0/24 network. What is the simplest way to accomplish this? Using CentOS 7.6.1810, docker 18.09.0, build 4d60db4.

Also, do the cool kids use /etc/docker/daemon.json or /etc/sysconfig/docker to control settings? Not sure if using systemd is the best option for docker.

已采纳解答

原帖链接 · BMitch · CC BY-SA 4.0

You do not want a bridge defined with the same subnet as your host ethernet. Linux will not know which network to send packets to since they both have the same routing entry. If you really need separate IP addresses for containers (this is a very non-traditional configuration), then you want macvlan or ipvlan.

Note that using host networking will expose all host interfaces to the container, which many consider a security risk. Containers running with this setting have the same network access as a process running outside of a container.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-12-17)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。