Docker Debug from Visual Studio 2022 works and opens the Web API, but trying to run image from Powershell does not work, port not being listened


Code is present in https://github.com/Coop202406/CountryAPI

Trying to run the same image from Visual Studio and from Powershell. The image is run in a container in both cases, the container created by Visual Studio Docker Debug works but the container run from the Powersehll does not work when the localhost 8080 is searched.

Below is the command used to run image from Powershell
docker run --rm -it -p 8080 -p 8081 -e ASPNETCORE_URLS="https://+;http//+" -e ASPNETCORE_HTTPS_PORTS=8081 -e ASPNETCORE_KestrelCertificatesDefaultPassword="webapp" -e ASPNETCORE_ENVIRONMENT=Development -e ASPNETCORE_KestrelCertificatesDefaultPath=c:\https\aspnetapp.pfx -v $env:USERPROFILE.aspnet\https:C:\https\ countryapi:dev

The images show the difference in containers running from docker debug

and container run from powershell

Tried tracing the VS output console, difference in the build mount.
Tried docker.exe run -p :8080 , opens listening to port but says localhost:port not found

Leave a Reply

Your email address will not be published. Required fields are marked *