DotNet Docker构建失败



我有一个长期的Dockerfile工作得很好。然后最近我开始得到构建错误:

FROM microsoft/dotnet:sdk AS build-env
WORKDIR /app
# Copy csproj and restore as distinct layers
COPY MycompanyDAL/*.csproj ./
COPY MycompanyDAL/NuGet.config ./
RUN dotnet restore
# Copy everything else and build
COPY MycompanyDAL/. ./
RUN dotnet publish -c Release -o out
# Build runtime image
FROM microsoft/dotnet:aspnetcore-runtime
WORKDIR /app
COPY --from=build-env /app/out .
ENV ASPNETCORE_URLS=http://+:8080
ENTRYPOINT ["dotnet", "MycompanyDAL.dll"]

给出错误:

docker build -t icverify-data-access .
[+] Building 1.4s (5/5) FINISHED                                                                                                                                                                          
=> [internal] load build definition from Dockerfile                                                                                                                                                 0.0s
=> => transferring dockerfile: 512B                                                                                                                                                                 0.0s
=> [internal] load .dockerignore                                                                                                                                                                    0.0s
=> => transferring context: 139B                                                                                                                                                                    0.0s
=> CANCELED [internal] load metadata for docker.io/microsoft/dotnet:aspnetcore-runtime                                                                                                              1.2s
=> ERROR [internal] load metadata for docker.io/microsoft/dotnet:sdk                                                                                                                                1.2s
=> [auth] microsoft/dotnet:pull token for registry-1.docker.io                                                                                                                                      0.0s
------
> [internal] load metadata for docker.io/microsoft/dotnet:sdk:
------
failed to solve with frontend dockerfile.v0: failed to create LLB definition: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed

然后更新为:

FROM mcr.microsoft.com/dotnet/runtime AS base
WORKDIR /app
FROM mcr.microsoft.com/dotnet/sdk AS build
WORKDIR /src
#FROM mcr.microsoft.com/dotnet/sdk:5.0.10 AS build-env
#WORKDIR /app
# Copy csproj and restore as distinct layers
COPY MycompanyDAL/*.csproj ./
COPY MycompanyDAL/NuGet.config ./
RUN dotnet restore
# Copy everything else and build
FROM base AS publish
COPY MycompanyDAL/. ./
RUN dotnet publish -c Release -o out

# Build runtime image
FROM base AS final
WORKDIR /app
COPY --from=base /app/out .
ENV ASPNETCORE_URLS=http://+:8080
ENTRYPOINT ["dotnet", "MycompanyDAL.dll"]

但是这给出了相同的错误。我能够手动拉那些mcr,但它不能解决问题:

docker pull mcr.microsoft.com/dotnet/sdk:5.0

你的Dockerfile有很多问题,我已经在这里修复了

FROM mcr.microsoft.com/dotnet/aspnet AS base
WORKDIR /app
FROM mcr.microsoft.com/dotnet/sdk AS build
WORKDIR /src
# Copy csproj and restore as distinct layers
COPY MycompanyDAL/*.csproj ./
COPY MycompanyDAL/NuGet.config ./
RUN dotnet restore
# Copy everything else and build
FROM build AS publish
COPY MycompanyDAL/. ./
RUN dotnet publish -c Release -o out
# Build runtime image
FROM base AS final
WORKDIR /app
COPY --from=publish /src/out .
ENV ASPNETCORE_URLS=http://+:8080
ENTRYPOINT ["dotnet", "MycompanyDAL.dll"]

相关内容

  • 没有找到相关文章

最新更新