Different Docker 1.9 networks talk to each other?
I want to create two Docker 1.9 networks. Network A runs a web server, an application server, and a Postgres server (all containers). Network B runs a SMTP server and other containers. I need containers on Network A to get to Network B. Is it possible?
One Solution collect form web for “Different Docker 1.9 networks talk to each other?”
The libnetwork implementation includes an overlay mode:
The overlay driver implements networking that can span multiple hosts using overlay network encapsulations such as VXLAN. For more details on its design, please see the Overlay Driver Design.
The new native overlay network driver supports multi-host networking natively out-of-the-box.
This support is accomplished with the help of libnetwork, a built-in VXLAN-based overlay network driver, and Docker’s libkv library.
This tutorial explains how to make containers talk to each other even if they are on different machines, provided they are registered to the same overlay network.
That will involve setting up first a K/V (Key/Value) store:
Now that your three nodes are configured to use the key-value store, you can create an overlay network on any node. When you create the network, it is distributed to all the nodes.
When you create your first overlay network on any host, Docker also creates another network on each host called
docker_gwbridge. Docker uses this network to provide external access for containers.
Every container in an overlay network also gets an
ethinterface in the
docker_gwbridgewhich allows the container to access the external world.
docker_gwbridgeis similar to Docker’s default
bridgenetwork, but unlike the
bridgeit restricts Inter-Container Communication(ICC).
Docker creates only one
docker_gwbridgebridge network per host regardless of the number of overlay networks present.
Docker added an entry to
/etc/hostsfor each container that belongs to the RED overlay network.
Therefore, to reach
container1, you can simply use its name. Docker automatically updates
/etc/hostswhen containers connect and disconnect from an overlay network.
At this point,
container3can communicate over the
They are both on the same
docker_gwbridgebut they cannot communicate using that bridge network without host-port mapping. The
docker_gwbridgeis used for all other traffic.