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

网络 – 覆盖码头网络中的–link和–alias之间的区别?

发布时间:2020-12-16 03:42:54 所属栏目:安全 来源:网络整理
导读:我正在阅读this官方Docker 0.10.3文档(此时,它仍在分支中)并且它说: --net-alias=ALIAS In addition to name as described above,a container is discovered by one or more of its configured net-alias (or alias in docker network connect command) wit

我正在阅读this官方Docker 0.10.3文档(此时,它仍在分支中)并且它说:

--net-alias=ALIAS

In addition to –name as described above,a container is discovered by one or more of its configured –net-alias (or –alias in docker network connect command) within the user-defined network. The embedded DNS server maintains the mapping between all of the container aliases and its IP address on a specific user-defined network. A container can have different aliases in different networks by using the –alias option in docker network connect command.

--link=CONTAINER_NAME:ALIAS

Using this option as you run a container gives the embedded DNS an extra entry named ALIAS that points to the IP address of the container identified by CONTAINER_NAME. When using –link the embedded DNS will guarantee that localized lookup result only on that container where the –link is used. This lets processes inside the new container connect to container without without having to know its name or IP.

来自一个容器的网络别名实际上是来自同一网络中第二个容器的链接吗?

最佳答案
–net-alias和–link之间有两点不同:

>使用–net-alias,只有当一个容器位于同一网络上时,才能访问另一个容器.换句话说,除了–net-alias foo和–net-alias bar之外,在使用docker network create foobar_net创建网络后,需要使用–net foobar_net启动两个容器.
>使用–net-alias foo,同一网络中的所有容器都可以使用其别名foo到达容器.使用–link,只有链接的容器可以使用名称foo到达容器.

从历史上看,–link是在libnetwork和所有与网络相关的功能之前创建的.在libnetwork之前,所有容器都在同一个网桥中运行,并且 – 仅将链接添加到/ etc / hosts.然后,添加了自定义网络和the behavior of --link in user-defined networks was changed.

有关–link的更多信息,另请参见Legacy container links.

(编辑:李大同)

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

    推荐文章
      热点阅读