适用于Windows的Docker Desktop:无法从Windows容器ping google.com

时间:2017-05-24 18:21:33

标签: docker docker-for-windows docker-desktop

我正在使用microsoft/windowsservercore图片创建容器。然后当我尝试从容器内部ping google.com时,我收到了这个错误:

  

Ping请求无法找到主机www.google.com。请检查名称   然后再试一次。

然后我在docker for Windows中切换到Linux Container模式。然后在ubuntu容器中尝试相同,但这次它工作正常。然后,当我切换回Windows Container模式并再次尝试相同的事情时,这次工作。虽然我的问题已经解决,但我仍然不了解导致这个问题的原因是什么?

1 个答案:

答案 0 :(得分:1)

Docker for windows and linux have different default network settings. Typically, the default for linux is bridged mode while in windows you have NAT.

You can alter your configuration with Network Connection Settings for windows

See: https://docs.docker.com/docker-for-windows/#network

The first option for me is always to look at the network section when executing docker inspect *containername*. This command gives you information about your network settings for the container. Other options are to check your firewall settings.

In general I usually use ping 8.8.8.8 since www.google.com cannot be pinged even from my standard windows machine.