简体   繁体   English

如何从命令行运行 Visual Studio 生成的 ASP.NET Core 示例 Web 应用 Docker 映像?

[英]How to run Visual Studio generated ASP.NET Core Sample Web App Docker image from command line?

I have我有

  1. Forked the [planetaryDocs][1] project (a sample server resident Blazor Web App),分叉 [planetaryDocs][1] 项目(示例服务器驻留 Blazor Web 应用程序),
  2. Used Visual Studio 2022 to create a docker container使用 Visual Studio 2022 创建 docker 容器
  3. Run that docker container (via Visual Studio) and运行那个 docker 容器(通过 Visual Studio)和

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.

相关问题 ASP.Net Core应用程序可在Visual Studio中运行,但不能与dotnet运行 - ASP.Net Core app works in visual studio but not with dotnet run 如何在不使用 Visual Studio 的情况下直接在 Dockers 容器上运行 ASP.NET Core Web 应用程序 - How to run an ASP.NET Core Web Application on Dockers container directly without using Visual Studio 如何从Visual Studio Team Services运行ASP.NET Core Entity Framework迁移 - How do I run ASP.NET Core Entity Framework migrations from Visual Studio Team Services 将命令行参数传递给Visual Studio容器工具中.NET Core控制台应用程序的Docker调试运行 - Pass command line args to a Docker debugging run of a .NET Core console application in Visual Studio Container Tools 优雅地停止 ASP.NET Core Web App(从 Visual Studio 调试器中),一个与 IHostedService 相关的问题 - Gracefully stopping ASP.NET Core Web App (from within Visual Studio debugger), an IHostedService-related question 将 Visual Studio 调试器与在 Kubernetes 中运行的 ASP.NET Core Web 应用程序一起使用? - Use Visual Studio debugger with ASP.NET Core web app running in Kubernetes? 如何在 ASP.NET Core 3.1 中使用 Visual Studio 2019 在 docker 中设置环境? - How to set the environment in a docker with Visual Studio 2019 in ASP.NET Core 3.1? ASP.NET Visual Studio Codespaces 中的核心应用程序调试问题 - ASP.NET Core app in Visual Studio Codespaces debugging issue Visual Studio 2019 中缺少 ASP.NET 核心 Web 应用程序 - Missing ASP.NET Core Web Application from Visual Studio 2019 在使用 visual studio 2019 运行应用程序时,如何防止在 Asp.Net Core API 3.1 中自动生成 web.config? - How to prevent auto-generated web.config in Asp.Net Core API 3.1 while running the application using visual studio 2019?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM