Docker Community Forums

Share and learn in the Docker community.

Multiple Ethernet port in docker container


(Rohitsukhwal) #1

I have two hardware interface on my host machine. I want to use both of these interface in all containers which I will create on host machine. So what is the best way to do that?
I tried these things:-

  1. I created container with default bridge network and then created one more bridge network with “docker network create -d bridge -o parent=host_interface bridge_name”. But when I attach it to container the default container interface stops working.

  2. I tried adding through pipework (sudo ./pipework “host_interface” “container_name” dhclient) also but no success.

So please suggest me how I can do that.
Thanks
Rohit


(David Maze) #2

If you use the default Docker setup, I’m pretty sure the ordinary -p option will allow inbound traffic from all interfaces. (And -p 10.20.30.40:80:80 will bind to a specific address on a specific interface.)

The Docker networking documentation doesn’t really discuss multiple host interfaces at all, but it also doesn’t mention the -o parent option you use at all. My guess would be that private bridge networks work the same way as the default network and that -p listens on all host interfaces unless specifically restricted.


(Rohitsukhwal) #3

Thank you so much David for reply.
I have two NIC eno1 (10…0.5.147) and eno2(10.0.5.184).
I want something like this
I want to map
10.0.5.147:random_port on host to 172.20.0.5:22 in docker container_1
10.0.5.184:random_port on host to 172.19.0.5:22 in docker container_1
So that I have two ip in docker container and if eno2 is not connected then 172.19.0.5:22 ip should not work.
Please help me with this.