简体   繁体   English

为什么我在使用macvlan时无法通过其主机名从外部计算机ping容器?

[英]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.

相关问题 我如何使用macvlan网络从外部主机ping本地docker容器? - How can i ping a local docker container from an outside host using macvlan network? Docker容器无法使用macvlan网络驱动程序访问或ping WAN - Docker container can't reach or ping WAN using macvlan network driver 有一种方法可以使用其主机名从另一个Docker容器ping Docker容器? - There is a way to ping a Docker container using its hostname, from another Docker Container? 为什么 Synology docker 容器无法 ping 通其主机 IP? - Why can't Synology docker container ping its host IP? 为什么docker容器不监听端口,我不能从另一个容器ping它 - Why docker container does not listen the port and I can't ping it from another container 为什么我不能从外部机器访问kafka? - Why i can't access kafka from an external machine? 为什么 SSH 不能从 GitLab public-runner 中的 Docker 容器到我的服务器,而我可以从我的机器使用相同的确切图像? - Why can't SSH to my server from Docker container inside a GitLab public-runner, while I can from my machine using the same exact image? 为什么我不能ping我的docker容器? - why I can't ping my docker container? "为什么我无法在 Windows 上 ping docker 容器?" - Why can't I ping docker container on Windows? Docker 1.10通过主机名从主机访问容器 - Docker 1.10 access a container by its hostname from a host machine
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM