Docker 链接容器、Docker 网络、组合网络 - 我们现在应该如何 'link' 容器
Docker linked containers, Docker Networks, Compose Networks - how should we now 'link' containers
我有一个现有的应用程序,它在同一主机上包含 4 个 docker 容器 运行。使用 link
命令将它们 link 编辑在一起。
然而,在 docker 的一些升级之后,link
行为已被弃用,并且似乎有所改变。我们遇到了容器现在彼此失去 link 的问题。
因此,docker 说要在 link
ed 容器上使用新的 Network
功能。但我看不出这是怎么回事。
如果 2 个容器在同一个网络中,相同的 ENV
变量是否会自动暴露在容器上,就好像它们是 linked 一样?
或者是否使用正确的容器名称/IP 地址更新了主机文件?即使在 docker restart
之后?
我在文档中看不到容器如何在其网络中找到另一个容器的位置?
另外,compose
看起来有一个简单的 linking 容器设置,并且可能会自动执行其中的一些操作 - compose 是定义多容器应用程序的方式吗?还是 运行 投入生产还为时过早?
compose
是否也支持多主机配置?
在未来的某个时候,我们可能需要将其中一个容器移动到不同的主机....
If 2 containers are in the same network, are the same ENV vars automatically exposed on the containers as if they were linked?
不,您现在必须使用容器名称作为它们的主机名。新的网络功能不知道将使用哪些端口。将此视为插入同一网络集线器的 2 台计算机。两者都可以通过主机名寻址对方。
is the hosts file updated with the correct container name / ip addresses ? Even after a docker restart ?
是的,属于网络一部分的所有容器的 /etc/hosts
文件将由 docker 引擎实时更新。
I can't see in the docs how a container can find the location of another in its network?
使用容器名称。请参阅 使用网络命令 文档的 Connect containers 部分:
连接后,容器可以使用另一个容器的 IP 地址或名称进行通信。
Also, compose looks to have a simple set up for linking containers, and may automate some of this - would compose be the way to go for defining multi container apps? Or is it too soon to run it in production?
Compose 通过提供 --x-networking
选项支持作为测试版的新网络功能。您不应该在生产中使用它(当前的 Compose 版本是 1.5)。
此外,目前的实现有点不方便,因为我们必须使用由项目名称 + _
+ [=34=组成的完整容器名称]容器名称 + _1
。 documentation 表示下一个版本(当前版本是 1.5)将对此进行改进,这样我们就不必担心 项目名称 来处理容器。
Does compose support multiple host configuration as well?
中详述的 Swarm 结合
我有一个现有的应用程序,它在同一主机上包含 4 个 docker 容器 运行。使用 link
命令将它们 link 编辑在一起。
然而,在 docker 的一些升级之后,link
行为已被弃用,并且似乎有所改变。我们遇到了容器现在彼此失去 link 的问题。
因此,docker 说要在 link
ed 容器上使用新的 Network
功能。但我看不出这是怎么回事。
如果 2 个容器在同一个网络中,相同的 ENV
变量是否会自动暴露在容器上,就好像它们是 linked 一样?
或者是否使用正确的容器名称/IP 地址更新了主机文件?即使在 docker restart
之后?
我在文档中看不到容器如何在其网络中找到另一个容器的位置?
另外,compose
看起来有一个简单的 linking 容器设置,并且可能会自动执行其中的一些操作 - compose 是定义多容器应用程序的方式吗?还是 运行 投入生产还为时过早?
compose
是否也支持多主机配置?
在未来的某个时候,我们可能需要将其中一个容器移动到不同的主机....
If 2 containers are in the same network, are the same ENV vars automatically exposed on the containers as if they were linked?
不,您现在必须使用容器名称作为它们的主机名。新的网络功能不知道将使用哪些端口。将此视为插入同一网络集线器的 2 台计算机。两者都可以通过主机名寻址对方。
is the hosts file updated with the correct container name / ip addresses ? Even after a docker restart ?
是的,属于网络一部分的所有容器的 /etc/hosts
文件将由 docker 引擎实时更新。
I can't see in the docs how a container can find the location of another in its network?
使用容器名称。请参阅 使用网络命令 文档的 Connect containers 部分: 连接后,容器可以使用另一个容器的 IP 地址或名称进行通信。
Also, compose looks to have a simple set up for linking containers, and may automate some of this - would compose be the way to go for defining multi container apps? Or is it too soon to run it in production?
Compose 通过提供 --x-networking
选项支持作为测试版的新网络功能。您不应该在生产中使用它(当前的 Compose 版本是 1.5)。
此外,目前的实现有点不方便,因为我们必须使用由项目名称 + _
+ [=34=组成的完整容器名称]容器名称 + _1
。 documentation 表示下一个版本(当前版本是 1.5)将对此进行改进,这样我们就不必担心 项目名称 来处理容器。
中详述的 Swarm 结合Does compose support multiple host configuration as well?