不同的Docker 1.9网络相互通话? [英] Different Docker 1.9 networks talk to each other?

查看:173
本文介绍了不同的Docker 1.9网络相互通话?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建两个Docker 1.9网络。网络A运行Web服务器,应用程序服务器和Postgres服务器(所有容器)。网络B运行SMTP服务器和其他容器。我需要网络A上的容器才能到达网络B.可以吗?

解决方案


现在你的三个节点被配置为使用键值存储,您可以在任何节点上创建覆盖网络。当您创建网络时,它将分发给所有节点。



当您在任何主机上创建第一个覆盖网络时,Docker还会在每个主机上创建名为 code> docker_gwbridge 。 Docker使用此网络为容器提供外部访问。



覆盖网络中的每个容器也可以获得一个 eth docker_gwbridge 中,允许容器访问外部世界。

$ code> docker_gwbridge 是类似的到Docker的默认桥梁网络,但与桥梁不同,它限制了集装箱间通信(ICC)。

Docker每个主机只创建一个 docker_gwbridge 桥接网络,无论存在的覆盖网络数量如何。



Docker为属于RED覆盖网络的每个容器添加了一个条目到 / etc / hosts

因此,要达到 container2 container1 ,您只需使用其名称即可。 Docker自动更新 / etc / hosts ,当容器连接并从覆盖网络断开连接时。



此时, container2 container3 可以通过 RED 覆盖网络。

它们都位于相同的 docker_gwbridge 上,但无法通过主机端口映射进行通信。 docker_gwbridge 用于所有其他流量。



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?

解决方案

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 eth interface in the docker_gwbridge which allows the container to access the external world.
The docker_gwbridge is similar to Docker's default bridge network, but unlike the bridge it restricts Inter-Container Communication(ICC).
Docker creates only one docker_gwbridge bridge network per host regardless of the number of overlay networks present.

Docker added an entry to /etc/hosts for each container that belongs to the RED overlay network.
Therefore, to reach container2 from container1, you can simply use its name. Docker automatically updates /etc/hosts when containers connect and disconnect from an overlay network.

At this point, container2 and container3 can communicate over the RED overlay network.
They are both on the same docker_gwbridge but they cannot communicate using that bridge network without host-port mapping. The docker_gwbridge is used for all other traffic.

这篇关于不同的Docker 1.9网络相互通话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆