Docker Community Forums

Share and learn in the Docker community.

Windows port mapping just ... stopped

Starting experimenting with creating some Windows containers. Initially had everything working (from a docker perspectrive), shut down the laptop … went home … and then things stopped being accessible from localhost.

The little project Im playing with can be found here: https://github.com/Justin-DynamicD/docker-windows-jenkins

the container builds, I can run it and add -p 8080:8080 and docker reports everything is NATed, but if I run a netstat or try a test-netconnection nothing is listening to the port. TO make sure it wasnt me I then went and grabbed a Windows IIS container off the doicker hub … and it also refuses to work.

docker run -d -p 80:80 --name test mcr.microsoft.com/windows/servercore/iis:windowsservercore-ltsc2019

this should allow local host… but alas no.

what baffles me is it worked before i packed up … whic h makes me think the toggling of network adapters broke something .

Anyone see anything like this?

So it looks like ther emay be a bug in the WinNAT driver. I was able to get things working by going direclty after the IP of the container. I actuall did two steps, and I’m not 100% if they are related, but here they are:

First, I did some deep diving (ok I googled) and found references to the shared nat network. Went to check it with:

get-netnat

This returned no results. Well that’s fun. So setup a shared NAT network with the following command:

New-NetNat -Name SharedNAT -InternalIPInterfaceAddressPrefix 172.16.0.1/20

THere we go. Ithen started the container in question. I still could not connect via localhost but then tried to check the IP:

docker exec jenkins ipconfig

Windows IP Configuration


Ethernet adapter Ethernet:
   Connection-specific DNS Suffix  . : <redacted.com>
   Link-local IPv6 Address . . . . . : fe80::c8f5:3b74:9f1f:6090%4
   IPv4 Address. . . . . . . . . . . : 172.17.231.154
   Subnet Mask . . . . . . . . . . . : 255.255.255.240
   Default Gateway . . . . . . . . . : 172.22.176.1
                                   172.17.231.145

connecting to http://172.17.231.154:8080 worked. Wierd, right?

I got the idea to add the sharedNAT when looking through old troubleshooting in github here:

I’ve not tried to remove this “netnat” and simply connect direclty yet. I also don’t know why “localhost” has just stopped working yet.

I have had the same problem from time to time. Restarting Docker via the context menu seems to repair it for me every time.

I have noticed that this problem happens when I shut down my host OS - not for sleep or hibernate.

I’ve had the same happen in the past, but for some reason the restart didn’t seem to help, which is frustrating. I can continue to use the dedicated IP for now, until I can get to the bottom of this … guess I can at least be glad I’m not alone in seeing this.