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

查看:1120
本文介绍了什么时候在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.

您可以使用只要您将两个容器都放在同一个网络上并且该网络不是默认的网桥,容器名称或容器的ID(短的12个字符)就可以使用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天全站免登陆