覆盖docker网络中的--link和--alias之间的区别? [英] Difference between --link and --alias in overlay docker network?

查看:511
本文介绍了覆盖docker网络中的--link和--alias之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读 Docker 0.10.3官方文档(目前仍在一个分支中),并显示:

I am reading this official Docker 0.10.3 documentation (at this time, it is still in a branch) and it says:

--net-alias=ALIAS




除上述--name之外,用户定义网络内的一个或多个已配置的--net-alias(或docker network connect命令中的--alias)会发现一个容器。嵌入式DNS服务器维护特定用户定义网络上所有容器别名与其IP地址之间的映射。通过在docker network connect命令中使用--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




使用此选项运行容器时,将为嵌入式DNS提供一个额外的条目ALIAS,该条目指向由CONTAINER_NAME标识的容器的IP地址。使用--link时,嵌入式DNS将保证仅在使用--link的容器上进行本地化查找。这使新容器内的进程无需知道其名称或IP即可连接到容器。

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.

实际上是从一个容器获取网络别名是同一网络中第二个容器的链接?

Does network alias from one container actually is a link from the second container in the same network?

推荐答案

之间有两个区别–净别名-link


  1. 使用-net-alias ,一个容器仅在它们位于同一网络中时才能访问另一个容器。换句话说,除了-net-alias foo -net-alias bar 外,您还需要使用-net foobar_net 启动两个容器,然后使用 docker network创建网络,创建foobar_net

  2. 使用-net-alias foo ,同一网络中的所有容器可以使用其别名<$ c来访问该容器$ c> foo 。使用-link 只有链接的容器可以使用名称 foo 。

  1. With --net-alias, one container can access the other container only if they are on the same network. In other words, in addition to --net-alias foo and --net-alias bar, you need to start both containers with --net foobar_net after creating the network with docker network create foobar_net.
  2. With --net-alias foo, all containers in the same network can reach the container by using its alias foo. With --link, only the linked container can reach the container by using the name foo.

从历史上看,-link 是在<$ c $之前创建的c> libnetwork 以及所有与网络相关的功能。在 libnetwork 之前,所有容器都在同一网络 bridge -link 中运行code>仅将名称添加到 / etc / hosts 。然后,添加了自定义网络,并且用户定义网络中-link 的行为已更改

Historically, --link was created before libnetwork and all network-related features. Before libnetwork, all containers ran in the same network bridge, and --link only added names to /etc/hosts. Then, custom networks were added and the behavior of --link in user-defined networks was changed.

请参见也旧版容器链接以获取有关的更多信息--link

这篇关于覆盖docker网络中的--link和--alias之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆