Docker Community Forums

Share and learn in the Docker community.

Making containers addressable on the same network as host?

(Gunnarniels) #1

I’ve found a lot of talk about this but nothing has seemed to work out for me, but this doesn’t seem like an unusual usecase…

I have a fresh CentOS7 bare metal server with docker version

Docker version 1.10.3, build cb079f6-unsupported
My LAN is, and my server statically lives at on that network. All I want to do is to be able to bring up containers at specified static addresses, so etc., and have these be accessible from other machines on the same network, like my laptop.

I have read that this can be accomplished via bridges, so I’ve configured a bridge using the one ethernet port on the server:

[arthas@arthas docker]$ cat /etc/sysconfig/network-scripts/ifcfg-eth0 
ETHTOOL_OPTS="autoneg off speed 100 duplex full"

[arthas@arthas docker]$ cat /etc/sysconfig/network-scripts/ifcfg-br0

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP qlen 1000
    link/ether 20:cf:30:3a:2a:ca brd ff:ff:ff:ff:ff:ff
3: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP 
    link/ether 20:cf:30:3a:2a:ca brd ff:ff:ff:ff:ff:ff
    inet brd scope global br0
       valid_lft forever preferred_lft forever

This all works fine, but I’m not sure of the correct way to coerce docker to use this bridge and allow me to assign ips to it. I tried using -b=br0 in the startup option, but the containers I brought up have no outside connection. I’ve also tried assigning specific ips to the containers via -ip, but I also had no luck there.

Could anyone point me in the right direction here? I want to make sure I do this the right way and that it’s persistent.