Connecting to a Windows container in NAT mode

I have an ASP.NET application running in a Windows container. The container is configured to use NAT mode. When I run the container I cannot connect to it using localhost from the docker host like I can on Linux. Instead I have to run docker exec to get the container’s IP address and connect to the container by it’s IP. Why does the Windows behavior differ from Linux? If I try connecting to the container while I’m off the docker host it works as expected; it’s only when I try connecting to the container while I’m on the docker host that this happens.

Yes, this is currently different than on Linux. Use the container IP if you’re on the host running the container:

docker inspect --format "{{.NetworkSettings.Networks.nat.IPAddress}}" <container-id>