Search code examples
asp.netdockerlocalhostcontainerswindows-container

Unable to access working web app on docker windows container via localhost


I am using Windows 10 ver. 1709 and docker 17.09.1-ce-win42 (using windows containers). I successfully created an image of my ASP.NET app with microsoft/aspnet as base image.

In order to create the container, I use the command:

docker run -d -p 8001:80 --name mycontainer myimage:v1.

The container is created properly, and if I want to access the website, I use the container's IP address known thanks to

docker inspect --format '{{ .NetworkSettings.Networks.nat.IPAddress }}' mycontainer

Despite that, I want to access my app through localhost:8001 - it does not work.

Can someone tell me if and what I did something wrong? I have read that mapping in windows containers is problematic.

Thanks in advance :)


Solution

  • This is known bug in Winnat implementation of Windows. No solution to this but either access by internal IP address or access it externally.

    Details

    Will be fixed in next edition of Windows

    https://blogs.technet.microsoft.com/networking/2017/11/06/available-to-windows-10-insiders-today-access-to-published-container-ports-via-localhost127-0-0-1/