• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

networking - 覆盖docker网络中--link和--alias之间的区别?

[复制链接]
菜鸟教程小白 发表于 2022-8-3 10:12:43 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

我正在阅读 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.



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



Best Answer-推荐答案


--net-alias之间有两个区别和 --link :

  • --net-alias ,一个容器只有在同一个网络上才能访问另一个容器。也就是说,除了--net-alias foo--net-alias bar ,您需要使用 --net foobar_net 启动两个容器使用 docker network create foobar_net 创建网络后.
  • --net-alias foo , 全部 同一网络中的容器可以通过别名foo 访问容器。 .与 --link , 只有链接的容器 可以使用名称 foo 访问容器.

  • 从历史上看,--link之前创建的 libnetwork以及所有与网络相关的功能。之前 libnetwork ,所有容器都在同一网络中运行 bridge , 和 --link仅将名称添加到 /etc/hosts .然后,添加了自定义网络和 the behavior of --link in user-defined networks was changed .

    另见 Legacy container links有关 --link 的更多信息.

    关于networking - 覆盖docker网络中--link和--alias之间的区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36048897/

    回复

    使用道具 举报

    懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    关注0

    粉丝2

    帖子830918

    发布主题
    阅读排行 更多
    广告位

    扫描微信二维码

    查看手机版网站

    随时了解更新最新资讯

    139-2527-9053

    在线客服(服务时间 9:00~18:00)

    在线QQ客服
    地址:深圳市南山区西丽大学城创智工业园
    电邮:jeky_zhao#qq.com
    移动电话:139-2527-9053

    Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap