[英]How to run Visual Studio generated ASP.NET Core Sample Web App Docker image from command line?
I have我有
and Visual Studio pops up a browser pointing at the web server and it seems to working fine.并且 Visual Studio 会弹出一个指向 Web 服务器的浏览器,它似乎工作正常。
When I do docker image ls
I see the planetarydocs image.当我执行
docker image ls
我看到了planetarydocs 图像。
I want to experiment with the docker run command line.我想试验 docker run 命令行。 How do I do that?
我怎么做? I stop the Visual Studio docker container and
我停止了 Visual Studio docker 容器并
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".我将浏览器指向 http://localhost:9090,浏览器显示“无法访问此页面”。
What am I doing wrong?我究竟做错了什么?
Thanks!谢谢!
Here is that is displayed with the above docker command:这是使用上述 docker 命令显示的内容:
{"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
Your run command is wrong.你的运行命令是错误的。 Any parameters to Docker need to go before the image name.
Docker 的任何参数都需要放在映像名称之前。 Any parameters after the image name override any CMD definition in the image.
图像名称后的任何参数都会覆盖图像中的任何 CMD 定义。
So instead of所以代替
docker.exe run planetarydocs -p 9090:80
you should do你应该做
docker.exe run -p 9090:80 planetarydocs
from the repository you pointed, the app seems to use port 8081.从您指向的存储库中,该应用程序似乎使用端口 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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.