Windows docker容器无法ping主机 [英] Windows docker container cannot ping host

查看:734
本文介绍了Windows docker容器无法ping主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Windows Server 2016主机上运行Windows docker容器,并运行默认配置。

I am running a windows docker container on a Windows Server 2016 host, running default configuration.

使用以下命令运行docker容器时:

When running the docker container using the command:

docker run -it microsoft / windowsservercore powershell

当我运行命令:

ping< hostIPAddress>

它只是说请求超时。
我已经检查过可以ping 8.8.8.8和google.com等...,甚至可以ping通同一子网中的其他计算机。我无法ping的唯一主机。

It just says that the request times out. I have checked that I can ping 8.8.8.8 and google.com etc... and even other machines on the same subnet. The only one I cannot ping is the host.

我在'docker run'命令中添加了'--dns',但这仅允许我通过主机名而不是IP来对主机进行ping操作。

I have added '--dns ' to the 'docker run' command but this only allows me to ping the host machine via hostname and not IP.

还有其他人看到此问题并找到解决方案吗?

Has anyone else seen this problem and have a solution?

推荐答案

我发现了一个解决方法(我不愿意将其称为解决方案):

I found a workaround (I'm not willing to call it a solution):

Windows容器网络驱动程序:创建一个透明网络:

Windows Container Network Drivers: create a 'transparent' network:

docker network create -d transparent trans

将容器附加到该网络

docker run --network=trans ...

重要:请注意,使用此网络,您的容器需要从主机子网中获取IP地址,并且直接暴露给它。

Important: Please note, that with this network, your container needs to obtain an IP Adress from the Host Subnet and it is directly exposed to it.

根据 https://github.com/Microsoft/Virtualization-Documentation/issues/ 253#issuecomment-217975932 (JMesser81):

According to https://github.com/Microsoft/Virtualization-Documentation/issues/253#issuecomment-217975932 (JMesser81):


这是Windows NAT实现(WinNAT)中的一个已知限制,您无法直接从容器(NAT)主机访问静态端口映射中的外部端口。

This is a known limitation in our Windows NAT implementation (WinNAT) that you cannot access the external port in a static port mapping directly from the container (NAT) host.

这篇关于Windows docker容器无法ping主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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