[英]Why I can't ping container by its hostname, from an external machine, while using macvlan?
I am creating a macvlan with this conf: 我用这个conf创建了一个macvlan:
sudo docker network create -d macvlan \
--subnet=192.168.4.0/24 \
--gateway=192.168.4.1 \
-o macvlan_mode=bridge \
-o parent=eth0 macvlan70
Then I run an alpine image using: 然后我使用以下运行高山图像:
docker run --net=macvlan70 --hostname=thehost --ip=192.168.4.17 -it alpine /bin/sh
At this moment I moved to another machine in LAN - host can't connect with Macvlan containers without a bridge. 此时我搬到了局域网中的另一台机器 - 主机无法连接没有桥接器的Macvlan容器。
I can ping 192.168.4.17
with success. 我可以成功ping 192.168.4.17
。 But ping thehost
will not result. 但ping thehost
不会导致。 In the router admin page the ip 192.168.4.17
is recognized but without the hostname associated. 在路由器管理页面中,可以识别ip 192.168.4.17
但没有关联的主机名。
As it's said in the docker docs , the user-defined hostname is not available from outside of the container. 正如在docker 文档中所述,用户定义的主机名不能从容器外部获得。
Even in host network mode a container has its own UTS namespace by default. 即使在主机网络模式下,默认情况下容器也有自己的UTS命名空间。 As such --hostname is allowed in host network mode and will only change the hostname inside the container 因此 - 在主机网络模式下允许使用hostname,并且只会更改容器内的主机名
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.