加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

网络-使用两个不同的名称将Docker容器添加到网络

发布时间:2020-12-16 03:23:31 所属栏目:安全 来源:网络整理
导读:我正在试验新的docker网络功能.我使用容器链接将旧设置迁移到新的网桥网络;到目前为止,我已经建立了专用的桥接网络并在同一主机上的多个容器之间运行. 现在,我正在寻找一种方法来为同一容器复制多个链接别名. 说,我有一个名为myBox的容器,该容器加入了docke

我正在试验新的docker网络功能.我使用容器链接将旧设置迁移到新的网桥网络;到目前为止,我已经建立了专用的桥接网络并在同一主机上的多个容器之间运行.
现在,我正在寻找一种方法来为同一容器复制多个链接别名.

说,我有一个名为myBox的容器,该容器加入了docker网络.我想拥有与myServer相同的容器.
使用链接,我将简单地设置两个具有不同别名的链接.
是否有使用Docker网络实现此目标的方法?

最佳答案
正在docker/libnetwork issue 737中指定和实现

We’d like a container to be able to join a network under different names,not just the container name.

这也将有助于Docker组成:请参阅docker/compose issue 2312.

When using the --x-networking feature in docker-compose 1.5 (docker-engine 1.9),is it possible to get a “simple name” added to /etc/hosts without knowing the container name beforehand and without using the container_name directive?

Update January 2016:

This is now done in 1.6.0 (RC1 is out)

参见“ Networking in Compose”

注意:Compose 1.5中引入的实验性标志–x-networking和–x-network-driver已被删除.

参见PR 19242和docker network connect

--alias option can be used to resolve the container by another name in the network being connected to.

$docker network connect --alias db --alias mysql multi-host-network container2

也:

You can use –link option to link another container with a prefered alias

$docker network connect --link container1:c1 multi-host-network container2

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读