码头连接两个容器如何知道彼此的ip [英] docker linking how can both containers know each others ip
问题描述
我可以有一个容器链接到B容器。
然后我可以请参阅A的ENV变量中的B的IP地址和暴露的端口。
但是,如何找出A的ip地址wihtin B容器?
要从其他容器中找到一个容器,您可以使用服务发现机制,例如 SkyDock 。
Skydock - Docker的自动化服务发现
Skydock监视停泊点事件容器启动,停止,死亡,杀死等,并将记录插入动态DNS服务器skydns。这允许在Docker容器内运行的服务进行标准DNS查询。
对于更复杂的情况,您的容器位于多个主机上,您需要一种将它们联网在一起的方式,请参阅 weave-dns (请注意,我在编织和编织dns上工作)。
From the docker linking
I can have A container links to B container.
Then I can see the B's ip address and exposed port in A's ENV variables.
However, how can I figure out A's ip address wihtin B container?
To find one container from another, you can use a 'service discovery' mechanism such as SkyDock.
Skydock - Automagic Service Discovery for Docker
Skydock monitors docker events when containers start, stop, die, kill, etc and inserts records into a dynamic DNS server skydns. This allows standard DNS queries for services running inside docker containers.
For the more complex case where your containers are on multiple hosts and you need a way to network them together, see weave-dns (Please note I work on weave and weave-dns).
这篇关于码头连接两个容器如何知道彼此的ip的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!