Run docker containers without Visual Studio.
I have a problem running any .Net project created in Visual Studio, without using Visual Studio UI to run the container.
In fact, the minimal reproductible steps are creating a new .net project and try to run the container using docker run or docker compose commands from the terminal.
Reproduction Steps:
Open Visual Studio and Create new project > ASP.NET Core Web Api > Keep the default configuration: WebApplication1 > .NET 7, configured for HTTPS, Enable for Docker (Linux), Controller, OpenApi Support.
Now we have a standard .NET API project. I defined the SSL port in the launch.settings.json so that every test can reuse the same url.
"Docker": {
…
"sslPort": 32769
}
Pressing the run button in Visual Studio opens up a browser at this url: https://localhost:32769/swagger/index.html that shows swagger working perfectly on the given port and in https
Now, I want to run this container without Visual Studio. For this reason I intercepted the run command that Visual Studio claims to run when starting the debugger (intercepting it from visual studio container tools)
1>docker run -dt -v "C:\Users\demur\vsdbg\vs2017u5:/remote_debugger:rw" -v "C:\Users\demur\AppData\Roaming\Microsoft\UserSecrets:/root/.microsoft/usersecrets:ro" -v "C:\Users\demur\AppData\Roaming\ASP.NET\Https:/root/.aspnet/https:ro" -v "C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Sdks\Microsoft.Docker.Sdk\tools\TokenService.Proxy\linux-x64\net7.0:/TokenService.Proxy:ro" -v "C:\Users\demur\source\repos\WebApplication1\WebApplication1:/app" -v "C:\Users\demur\source\repos\WebApplication1:/src/" -v "C:\Users\demur\.nuget\packages\:/root/.nuget/fallbackpackages" -e "ASPNETCORE_LOGGING__CONSOLE__DISABLECOLORS=true" -e "ASPNETCORE_ENVIRONMENT=Development" -e "ASPNETCORE_URLS=https://+:443;http://+:80" -e "ASPNETCORE_HTTPS_PORT=32769" -e "DOTNET_USE_POLLING_FILE_WATCHER=1" -e "NUGET_PACKAGES=/root/.nuget/fallbackpackages" -e "NUGET_FALLBACK_PACKAGES=/root/.nuget/fallbackpackages" -p 32769:443 -P --name WebApplication1 --entrypoint tail webapplication1:dev -f /dev/null
1>docker run -dt -v "C:\Users\demur\vsdbg\vs2017u5:/remote_debugger:rw" -v "C:\Users\demur\AppData\Roaming\Microsoft\UserSecrets:/root/.microsoft/usersecrets:ro" -v "C:\Users\demur\AppData\Roaming\ASP.NET\Https:/root/.aspnet/https:ro" -v "C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Sdks\Microsoft.Docker.Sdk\tools\TokenService.Proxy\linux-x64\net7.0:/TokenService.Proxy:ro" -v "C:\Users\demur\source\repos\WebApplication1\WebApplication1:/app" -v "C:\Users\demur\source\repos\WebApplication1:/src/" -v "C:\Users\demur\.nuget\packages\:/root/.nuget/fallbackpackages" -e "ASPNETCORE_LOGGING__CONSOLE__DISABLECOLORS=true" -e "ASPNETCORE_ENVIRONMENT=Development" -e "ASPNETCORE_URLS=https://+:443;http://+:80" -e "ASPNETCORE_HTTPS_PORT=32769" -e "DOTNET_USE_POLLING_FILE_WATCHER=1" -e "NUGET_PACKAGES=/root/.nuget/fallbackpackages" -e "NUGET_FALLBACK_PACKAGES=/root/.nuget/fallbackpackages" -p 32769:443 -P --name WebApplication1 --entrypoint tail webapplication1:dev -f /dev/null
So I delete Visual studio container, and run that command, a new container is created, but the browser on https://localhost:32769/swagger/index.html gives connection refused.
I tried playing with the arguments passed to the docker run, but I wasn't able to make one that works.
How can I run a simple .NET 7 project image in docker without visual studio?