第 5 章 在容器中运行 .NET 9.0 应用程序
使用 ubi8/dotnet-90-runtime
镜像在 Linux 容器中运行 .NET 应用程序。
以下示例使用 Podman。
流程
在名为
mvc_runtime_example
的目录中创建一个新的 MVC 项目:$ dotnet new mvc --output mvc_runtime_example
发布项目:
$ dotnet publish mvc_runtime_example -f net9.0 /p:PublishProfile=DefaultContainer /p:ContainerBaseImage=registry.access.redhat.com/ubi8/dotnet-90-runtime:latest
运行您的镜像:
$ podman run -rm -p8080:8080 mvc_runtime_example
查看容器中运行的应用程序:
$ xdg-open http://127.0.0.1:8080