Docker Community Forums

Share and learn in the Docker community.

Unable to connect to ASP.NET MVC app running in Windows Container

I was following this instruction for creating and running a Windows docker container. But I cannot get it to work, I tried from two different machines with the same result.

Instructions are here.

I started from the basic template project for ASP.NET (framework) MVC app - no HTTPS, using Visual Studio 2019. I published it according to the instructions in the post. and create a docker container exactly as described.

I’m able to create the container and run it, however when I navigate to localhost I am not able to reach the site.

It shows that its running on port 80

enter image description here

Does anyone have any recommendations how to get this working? Perhaps the instructions are missing a step?

I’m using latest version of Docker for Windows, Windows 10 x64 Pro latest version , I think 1909

EDIT: With the container running I ran docker inspect on the container id and in the NetworkSettings I got the “IPAddress”: “172.17.50.25”,. I then entered that into the browser and was able to access the app.

Can someone explain how this is working? And why accessing it via localhost doesn’t?

It looks like the Microsoft tutorial is overlooking that you’d need to add port mapping if you want to access the container’s service through localhost. Add - p 80:80 to the docker run command and see where that gets you.