Windows docker container cannot connect to computer

I am running a Windows docker container on a Windows Server 2016 host using the default configuration.

When starting a docker container with the command:

docker run -it microsoft/windowsservercore powershell

When I run the command:

ping <hostIPAddress>

It just says the request is about to expire. I have verified that I can ping 8.8.8.8 and google.com etc. And even other machines on the same subnet. The only one I can't ping with is the host.

I added "-dns" to the "docker run" command, but that only allows me to ping the host machine by hostname, not IP.

Has anyone else seen this problem and had a solution?

+3


source to share


2 answers


I found a workaround (I don't want to call this a solution):

Windows network container drivers : create transparent network:

docker network create -d transparent trans

      

Attach a container to this network

docker run --network=trans ...

      



Important . Note that on this network, your container needs to get an IP address from the host's subnet and it will be directly exposed to it.

may be related (this concerns access to containers from the host):

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

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

0


source


I faced the same problem.

My workaround is to restart the docker service, after which it works fine. I am still looking for a permanent solution.



root@a6c40eb25cbf:/# ping xxx.xx.xx.xxx
PING xxx.xx.xx.xxx (xxx.xx.xx.xxx): 56 data bytes
64 bytes from xxx.xx.xx.xxx: icmp_seq=0 ttl=37 time=3.541 ms
64 bytes from xxx.xx.xx.xxx: icmp_seq=1 ttl=37 time=2.643 ms
64 bytes from xxx.xx.xx.xxx: icmp_seq=2 ttl=37 time=1.857 ms
^C--- xxx.xx.xx.xxx ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss

      

0


source







All Articles