After creating an ASP.NET Core app from web template in Visual Studio and clicking Add Docker Support, it runs fine in debug mode initiated by Visual Studio.
However if debugging is stopped in Visual Studio then the container no longer responds even though it is still running and can be entered via terminal etc. The ports are still listening but it just doesn’t work anymore.
Start debugging
Stop debugging
All other info above remains the same with no indication the container is even aware Visual Studio has stopped. The container is still accessible:
The mapped ports are still listening so there is a process backing the socket:
But the site no longer works:
What is Visual Studio doing to make this container respond? Where is the documentation for it?
2
Answers
Have you tried Ctrl+F5 (start without debugging)? also change the settings in Tools-Configuration-Containers then look for the options where it gets rid of the containers on close and set them to false. That allowed me to run my asp page with docker without debug being active in VS22.
Apparently Visual Studio does some tricks when building for debugging so the image doesn’t work without VS. If you build the image yourself with
docker build
, it’ll work in Docker Desktop.