ubuntu/dotnet-runtime本文档介绍由Canonical提供的基于Ubuntu的dotnet-runtime Docker镜像。该镜像接收安全更新,并会滚动更新至新版本的dotnet-runtime或Ubuntu发行版。本仓库可免费使用,且不受每用户速率限制影响。
.NET是一个免费、跨平台、开源的开发平台,用于构建多种类型的应用程序。通过.NET,您可以使用多种语言、编辑器和库构建Web、移动、桌面、游戏、物联网等应用。如需了解如何使用容器镜像部署.NET应用,请参阅.NET文档。
本镜像不包含bash、包管理器及.NET SDK。
精简版Ubuntu for .NET是一类新型OCI镜像,更多信息请参见Ubuntu博客,了解Canonical与Microsoft如何合作提供和支持Ubuntu上的.NET。
ubuntu/dotnet-deps仓库ubuntu/dotnet-aspnet仓库dotnet-aspnet镜像)!LTS
LTS通道提供长达5年的免费安全维护
!ESM
通过Canonical的受限仓库提供长达10年的客户安全维护(扩展安全维护)
| 通道标签 | 支持期限 | 当前版本 | 架构 |
|---|---|---|---|
8.0-24.04_stable8.0, 8.0-24.04_148, 8.0-24.04_beta, 8.0-24.04_beta_148, 8.0-24.04_candidate, 8.0-24.04_candidate_148, 8.0-24.04_edge, 8.0-24.04_edge_148, 8.0-24.04_stable_148, 8.0_beta, 8.0_candidate, 8.0_edge, 8.0_stable, beta, candidate, edge, stable | 11/2026 | Ubuntu 24.04 LTS上的dotnet-runtime 8.0 | amd64, arm64, ppc64le, s390x |
9.0-25.04_edge | 01/2026 | Ubuntu 25.04上的dotnet-runtime 9.0 | amd64, arm64 |
通道标签按稳定性排序为 stable(稳定)、candidate(候选)、beta(测试)、edge(边缘)。风险较高的通道始终隐含可用:若列出beta,则可拉取edge;若列出candidate,则可拉取beta和edge;若列出stable,则四个通道均可用。镜像会按edge→beta→candidate→stable的顺序发布。
如涉及商业再分发,或需要ESM及未列出的通道/版本,请联系Canonical团队(或发送邮件至***)。
shdocker run -d --name dotnet-runtime-container -e TZ=UTC ubuntu/dotnet-runtime:8.0-24.04_stable
TZ:设置容器时区,如UTC、Asia/Shanghai等pebble6.0、8.0及9.0-24.10版本:基于Dockerfile构建,入口点为dotnet
直接运行镜像将显示.NET帮助信息:
sh$ docker run --rm ubuntu/dotnet-runtime:8.0-24.04_stable Host: Version: 8.0.16 ...
9.0-25.04及更高版本:基于Rock构建,入口点为pebble enter(Pebble是Canonical的轻量级服务管理器)。需通过exec命令访问dotnet:
sh$ docker run --rm ubuntu/dotnet-runtime:9.0-25.04_edge exec dotnet Usage: dotnet [options] ...
创建示例应用(HelloWorld.csproj和Program.cs):
xml<!-- HelloWorld.csproj --> <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework>net8.0</TargetFramework> <ImplicitUsings>enable</ImplicitUsings> <Nullable>enable</Nullable> </PropertyGroup> </Project>
csharp// Program.cs Console.WriteLine("Hello, World!");
发布应用:
shdotnet publish -c Release -o app
运行容器:
shdocker run --rm -v $PWD/app:/app ubuntu/dotnet-runtime:8.0-24.04_stable /app/HelloWorld.dll Hello, World!
修改项目文件的TargetFramework为net9.0,发布应用:
shdotnet publish -c Release -o app
运行容器:
shdocker run --rm -v $PWD/app:/app ubuntu/dotnet-runtime:9.0-25.04_edge exec dotnet /app/HelloWorld.dll Hello, World!
dockerfile# 构建阶段:使用Ubuntu 24.04安装SDK并编译应用 FROM ubuntu:24.04 AS builder RUN apt-get update && apt-get install -y dotnet8 ca-certificates WORKDIR /source COPY . . RUN dotnet publish -c Release -o /app # 运行阶段:基于dotnet-runtime镜像 FROM ubuntu/dotnet-runtime:8.0-24.04_beta WORKDIR /app COPY --from=builder /app ./ ENTRYPOINT ["dotnet", "/app/HelloWorld.dll"]
dockerfile# 构建阶段:使用Ubuntu 25.04安装SDK并编译应用 FROM ubuntu:25.04 AS builder RUN apt-get update && apt-get install -y dotnet9 ca-certificates WORKDIR /source COPY . . RUN dotnet publish -c Release -o /app # 运行阶段:基于dotnet-runtime镜像 FROM ubuntu/dotnet-runtime:9.0-25.04_edge WORKDIR /app COPY --from=builder /app ./ CMD ["exec", "dotnet", "/app/HelloWorld.dll"]
查看容器日志:
shdocker logs -f dotnet-runtime-container
9.0-25.04及更高版本:通过Pebble查看日志:
shdocker exec -it dotnet-runtime-container pebble logs
如发现镜像 bug 或需请求功能,请提交issue至:
[***]
标题格式为 "dotnet-runtime: <问题摘要>",并附镜像摘要(通过以下命令获取):
shdocker images --no-trunc --quiet ubuntu/dotnet-runtime:<tag>
以下通道(标签)不再更新,请升级至新版本,或联系Canonical获取支持。
| 通道 | 版本 | 生命周期结束(EOL) | 升级路径 |
|---|---|---|---|
| Ubuntu 24.10上的dotnet-runtime 9.0 | 07/2025 | - | |
| Ubuntu 22.04 LTS上的dotnet-runtime 6.0 | 11/2024 | - | |
| Ubuntu 23.04上的dotnet-runtime 7.0 | 05/2024 | - | |
| Ubuntu 22.10上的dotnet-runtime 6.0 | 07/2023 | - | |
| Ubuntu 22.10上的dotnet-runtime 7.0 | 07/2023 | - |


manifest unknown 错误
TLS 证书验证失败
DNS 解析超时
410 错误:版本过低
402 错误:流量耗尽
身份认证失败错误
429 限流错误
凭证保存错误
来自真实用户的反馈,见证轩辕镜像的优质服务