码头连接两个容器如何知道彼此的ip

编程入门 行业动态 更新时间:2024-10-27 10:30:17
本文介绍了码头连接两个容器如何知道彼此的ip的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

$ p

我可以有一个容器链接到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

本文发布于:2023-10-08 10:00:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1472298.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:容器   码头   两个   ip

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!