何时在 docker 中使用 --hostname? [英] When to use --hostname in docker?

查看:73
本文介绍了何时在 docker 中使用 --hostname?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

--hostname 是不是像docker容器环境中的域名系统,在引用其他容器时可以代替--ip?

Is --hostname like a domain name system in docker container environment that can replace --ip when referring to other container?

推荐答案

--hostname 标志仅更改容器内的主机名.如果您的应用程序需要主机名的特定值,则可能需要这样做.它不会更改 docker 之外的 DNS,也不会更改网络隔离,因此不会允许其他人连接到具有该名称的容器.

The --hostname flag only changes the hostname inside your container. This may be needed if your application expects a specific value for the hostname. It does not change DNS outside of docker, nor does it change the networking isolation, so it will not allow others to connect to the container with that name.

您可以使用容器名称或容器的(短的,12 个字符)ID 来从容器连接到带有 docker 嵌入式 dns 的容器,只要您在同一网络上拥有两个容器并且该网络不是默认网桥.

You can use the container name or the container's (short, 12 character) id to connect from container to container with docker's embedded dns as long as you have both containers on the same network and that network is not the default bridge.

这篇关于何时在 docker 中使用 --hostname?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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