Home > Mobile >  How to run Visual Studio generated ASP.NET Core Sample Web App Docker image from command line?
How to run Visual Studio generated ASP.NET Core Sample Web App Docker image from command line?

Time:12-31

I have

  1. Forked the [planetaryDocs][1] project (a sample server resident Blazor Web App),
  2. Used Visual Studio 2022 to create a docker container
  3. Run that docker container (via Visual Studio) and

and Visual Studio pops up a browser pointing at the web server and it seems to working fine.

When I do docker image ls I see the planetarydocs image.

I want to experiment with the docker run command line. How do I do that? I stop the Visual Studio docker container and

docker.exe run planetarydocs  -p 9090:80

This does not work.

I point my browser at http://localhost:9090 and the browser says "cannot reach this page".

What am I doing wrong?

Thanks!

Here is that is displayed with the above docker command:

   {"EventId":35,"LogLevel":"Warning","Category":"Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager","Message":"No XML encryptor configured. Key {3df3c08f-884d-49fe-a4f8-163ea6058090} may be persisted to storage in unencrypted form.","State":{"Message":"No XML encryptor configured. Key {3df3c08f-884d-49fe-a4f8-163ea6058090} may be persisted to storage in unencrypted form.","KeyId":"3df3c08f-884d-49fe-a4f8-163ea6058090","{OriginalFormat}":"No XML encryptor configured. Key {KeyId:B} may be persisted to storage in unencrypted form."}}
   {"EventId":14,"LogLevel":"Information","Category":"Microsoft.Hosting.Lifetime","Message":"Now listening on: http://[::]:80","State":{"Message":"Now listening on: http://[::]:80","address":"http://[::]:80","{OriginalFormat}":"Now listening on: {address}"}}
   {"EventId":0,"LogLevel":"Information","Category":"Microsoft.Hosting.Lifetime","Message":"Application started. Press Ctrl\u002BC to shut down.","State":{"Message":"Application started. Press Ctrl\u002BC to shut down.","{OriginalFormat}":"Application started. Press Ctrl\u002BC to shut down."}}
   {"EventId":0,"LogLevel":"Information","Category":"Microsoft.Hosting.Lifetime","Message":"Hosting environment: Production","State":{"Message":"Hosting environment: Production","envName":"Production","{OriginalFormat}":"Hosting environment: {envName}"}}
   {"EventId":0,"LogLevel":"Information","Category":"Microsoft.Hosting.Lifetime","Message":"Content root path: /app","State":{"Message":"Content root path: /app","contentRoot":"/app","{OriginalFormat}":"Content root path: {contentRoot}"}}```


 [1]: https://github.com/JeremyLikness/PlanetaryDocs

CodePudding user response:

Your run command is wrong. Any parameters to Docker need to go before the image name. Any parameters after the image name override any CMD definition in the image.

So instead of

docker.exe run planetarydocs  -p 9090:80

you should do

docker.exe run -p 9090:80 planetarydocs

CodePudding user response:

from the repository you pointed, the app seems to use port 8081.

PlanetaryDocs/appsettings.json

"EndPoint": "https://localhost:8081/",

if you haven't changed it,try this command using that port instead

docker.exe run planetarydocs  -p 9090:8081
  • Related