Docker Community Forums

Share and learn in the Docker community.

How to set interface name for a new container?



I am trying to connect two containers through a bridge.

     docker network create --subnet --driver bridge br0_nw
     docker network connect --ip br0_nw cont1
     docker network connect --ip br0_nw cont2

However, I got this error, because I already create interface eth1 for another purpose before this step, and docker wants to add a new interface with the same name!

Error response from daemon: failed to add interface veth61751e9 to sandbox: error renaming interface "veth61751e9" to "eth1": file exists

Is there any option like interface-name :

     docker network connect --ip --interface-name ethx br0_nw cont1

Here is my setup, I have connected server, client, Bro containers to OVS switch using ovs-docker tool.
And I use docker bridge to connect bro and SDN controller but since bro eth1 is already in use, bridge connection fails with the above error message.



(Tekki) #2

The simplest way to connect two containers is to start them in the same docker-compose file. Then they can access each other using the name you gave them under services.

(Martin Terp) #3


Is there a reason you want to create another bridge network?
If its because you want to connect multiple interfaces to your container, you should be able to do:
docker run -ti -p x.x.x.x:8080:8080 -p y.y.y.y:80:80 image...


I will try that, thank you!


I am trying to allow two containers ssh each other. Is there a way to do that other than bridge or docker-compose.