Docker: how to connect two bridges

As you know after Docker 1.9 we can create bridges to connect containers.

I have created two custom bridges: bridge A 172.18.0.1 and bridge B 172.19.0.1.

  • coreos docker 1.7.1 -v file.txt:file.txt not updating
  • How to install the latest Docker .deb package?
  • How do I connect to a docker container running on a different host on a mac?
  • Where to put ebextensions config in AWS Elastic Beanstalk Docker deploy with dockerrun source bundle?
  • Varnish/Symfony3 Cache on Nginx - Ago 0 on caching
  • How to automate docker deployment based on GitHub webhook?
  • Now I have a container1 on bridge A, and a container2 on bridge B called “mailServer”.

    The container1 needs to reach container2 by a DNS, how should I do this? Because they are on different bridges so they cannot talk to each other. Do I need a router and can I achieve this by Docker?

    This is a new feature of Docker and I didn’t find much information. Thanks.

  • Can run ARM/rpi images in Docker on Windows but not linux
  • Docker not releasing memory when shutdown, windows 10
  • docker client daemon access remote swarm `1.12.1` manager
  • Can not register more than one subdomain this nginx and nginx-proxy with docker container
  • Neo4j 2.3.2 to cloud foundry
  • CHEF provisioning: SystemStackError: stack level too deep
  • 3 Solutions collect form web for “Docker: how to connect two bridges”

    You can try making use of the veth peer so that you can connect two bridges. Make sure you are rename and names respectively with the one you configured.

    ip link add veth0 type veth peer name veth1
    ifconfig veth0 up
    ifconfig veth1 up
    brctl addif <D1-A-Bridge> veth0
    brctl addif <D2-A-Bridge> veth1
    

    To connect container2 to container1 you can also connect it to bridgeB

    $ docker network connect bridgeB container1
    

    This will allow container1 to connect to container2 by IP address, DNS names would still have to be updated manually afaik.

    More information in the Docker networking guide here.

    If you want to connect two bridges, you can use a pair of
    patch ports with open v-switch . The follow example creates bridges br0 and br1, adds eth0 and tap0 to br0, adds tap1 to br1, and then connects br0 and br1 with a pair of patch ports.

       ovs-vsctl add-br br0
       ovs-vsctl add-port br0 eth0
       ovs-vsctl add-port br0 tap0
       ovs-vsctl add-br br1
       ovs-vsctl add-port br1 tap1
       ovs-vsctl \
           -- add-port br0 patch0 \
           -- set interface patch0 type=patch options:peer=patch1 \
           -- add-port br1 patch1 \
           -- set interface patch1 type=patch options:peer=patch0
    
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.