I would like to make an API with Visual Studio and put it in a container, to be able to execute in any other computer BUT without using Visual Studio. Just running the container.
I launched Visual Studio 2019, selected a new project with the API template and I got the weatherforecast Web Application example with the controller and the WeatherForeCast class. I launch it with 'IIS' and runs perfect, I run it with 'Docker' and runs great (it create the container and I verify it via Docker Desktop). I try the app writing in Chrome/FireFox/IE: https://localhost:container_port/weatherforecast
After that, if close Visual Studio and I still have the container running, and I try again https://localhost:container_port/weatherforecast, it doesn't work. I have checked the ports, I have also stopped the container and run it again (it start with new ports, checked in docekr desktop or with 'docker ps' with power shell) and I try again with https://localhost:container_new_port/weatherforecast and it doesn't work until I start again Visual Studio and click on 'Docker'. It seems there is a link between the container and Visual Studio, something I don't understand because container are really to be independent from anything.
Other people has the same problem, but no solution worked for me: How to access a website running on docker after closing the debug on Visual Studio ASP.NET Core Docker container only responds when debugging in visual studio why is my docker container ASP.NET core app not available after ending debugging in Visual Studio
¿Any help? If anybody ask you to build an app with visual studio BUT to be run in a container without using VS, what would you do? Thanks for your time.
You seem to have run into an artifact of the debugging optimizations used in VS: http://aka.ms/containerfastmode. If you do a full build of the Dockerfile (right click in VS, or build from the command line [Note: the build context is the solution folder by default]) you'll get an image that works w/o VS running.