1

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.

  • Or should I be using macvlan networking in which case do I need a bridge0? – mr.zog Dec 17 '18 at 2:35
  • OK. I was overthinking this. 'docker run -d --net=host --name mysql-8.1 -e MYSQL_ROOT_PASSWORD=d0ngB3rT -d mysql:latest' exposes the service:port to the host network. – mr.zog Dec 18 '18 at 3:41
  • (No actual passwords displayed.) – mr.zog Dec 18 '18 at 3:50
1

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.

| improve this answer | |
0

There was no need to modify the default docker network stack. All I needed was to specify the host network ( --net=host ) to make the listener available to my LAN. docker run -d --net=host --name { container_name } { options }

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.