mcr.microsoft.com/dotnet/sdk:8.0
我有一个用于构建一个 .net8 C# 应用程序的 Dockerfile 。之前 Dockerfile 使用mcr.microsoft.com/dotnet/sdk:6.0
Inside I have a command RUN sed -i -e's/ main/ main contrib/g' /etc/apt/sources.list
。当我尝试构建图像时出现错误
ERROR: failed to solve: process "/bin/sh -c sed -i -e's/ main/ main contrib/g' /etc/apt/sources.list" did not complete successfully: exit code: 2
内部错误是:
#11 [ 7/18] RUN sed -i -e's/ main/ main contrib/g' /etc/apt/sources.list
#11 0.249 sed: can't read /etc/apt/sources.list: No such file or directory
我看到它mcr.microsoft.com/dotnet/sdk:6.0
基于 Debian 11,并且mcr.microsoft.com/dotnet/sdk:8.0
基于 Debian 12,所以我在我的电脑上提取了两个 docker 镜像并运行这两个容器。
在 Debian 11 上我有/etc/apt/sources.list
,但在 Debian 12 上我没有:
我是否做错了什么,如何解决这个问题?
问候,朱利安
答案1
Debian 12 镜像不发送/etc/apt/sources.list
文件,而是使用文件输入/etc/apt/sources.list.d
,debian.sources
。
答案2
尝试RUN sed -i 's/^Components: main$/& contrib/' /etc/apt/sources.list.d/debian.sources