如何在 Docker 容器内使用 Angular 模板运行 ASP.NET Core?

use*_*444 5 asp.net docker angular

脚步

  1. 使用 Visual Studio 和 ASP.NET Core 以及 Angular 项目模板创建一个新项目。(其他设置:.NET 6.0、启用 HTTPS、无身份验证)

角度项目模板

  1. 添加容器编排支持(其他设置:Docker Compose、Linux)

添加容器编排支持

  1. 通过 VS 使用 Docker Compose 配置运行项目

运行项目

结果

  1. 浏览器打开,但仅显示 HTTP 404 Not Found 错误。

  2. 容器日志并没有真正的帮助。

{"EventId":60,"LogLevel":"Warning","Category":"Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository","Message":"Storing keys in a directory \u0027/root/.aspnet/DataProtection-Keys\u0027 that may not be persisted outside of the container. Protected data will be unavailable when container is destroyed.","State":{"Message":"Storing keys in a directory \u0027/root/.aspnet/DataProtection-Keys\u0027 that may not be persisted outside of the container. Protected data will be unavailable when container is destroyed.","path":"/root/.aspnet/DataProtection-Keys","{OriginalFormat}":"Storing keys in a directory \u0027{path}\u0027 that may not be persisted outside of the container. Protected data will be unavailable when container is destroyed."}}
{"EventId":35,"LogLevel":"Warning","Category":"Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager","Message":"No XML encryptor configured. Key {834abb8d-55b6-4f29-b1a6-4aa8a6468f9e} may be persisted to storage in unencrypted form.","State":{"Message":"No XML encryptor configured. Key {834abb8d-55b6-4f29-b1a6-4aa8a6468f9e} may be persisted to storage in unencrypted form.","KeyId":"834abb8d-55b6-4f29-b1a6-4aa8a6468f9e","{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: https://[::]:443","State":{"Message":"Now listening on: https://[::]:443","address":"https://[::]:443","{OriginalFormat}":"Now listening on: {address}"}}
{"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: Development","State":{"Message":"Hosting environment: Development","envName":"Development","{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}"}}
Run Code Online (Sandbox Code Playgroud)

我需要这个项目在 Docker 上运行。如何才能做到这一点?

我知道 Node 没有安装在 Docker 容器中,但知道这一点并没有什么帮助。如何修复它?