Docker 构建拉取访问被拒绝,存储库不存在或可能需要
Docker build pull access denied, repository does not exist or may require
我试图在不使用 Visual Studio 的情况下生成 Docker 图像。我在项目文件夹中,我从 windows 10 管理命令行 docker build .
执行我不知道如何使它工作。
[+] Building 1.3s (8/9)
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 753B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 34B 0.0s
=> [internal] load metadata for mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim 0.0s
=> [base 1/2] FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim 0.0s
=> ERROR FROM docker.io/publish/app:latest 1.2s
=> => resolve docker.io/publish/app:latest 1.2s
=> CACHED [base 2/2] WORKDIR /app 0.0s
=> CACHED [final 1/2] WORKDIR /app 0.0s
=> [auth] publish/app:pull token for registry-1.docker.io 0.0s
------
> FROM docker.io/publish/app:latest:
------
failed to load cache key: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed
这是我的 dockerfile:
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /src
COPY ["src/App.Web/App.Web.csproj", "src/App.Web/"]
RUN dotnet restore "App.Web.csproj"
COPY . .
WORKDIR "/src/App.Web"
RUN dotnet build App.Web.csproj -c Debug -o /app
FROM build as debug
RUN dotnet publish "App.Web.csproj" -c Debug -o /app
FROM base as final
WORKDIR /app
COPY --from=publish/app /app .
ENTRYPOINT ["dotnet","App.Web.dll"]
您登录了吗?尝试 docker login
然后再次执行 docker build
正如我在此处看到的那样 aspnet in docker hub 您打算使用的存储库已重命名。请改用以下内容
from mcr.microsoft.com/dotnet/aspnet:3.1-buster-slim
存储库已重命名,可以在此处找到类似的问题
您有称为基础、构建和调试的阶段。那么在最后阶段你有:
COPY --from=publish/app /app .
当 docker 找不到具有该名称 publish/app
的舞台时,它会尝试查找不存在的图像。我猜你想从构建阶段复制,例如
COPY --from=build /app .
我试图在不使用 Visual Studio 的情况下生成 Docker 图像。我在项目文件夹中,我从 windows 10 管理命令行 docker build .
执行我不知道如何使它工作。
[+] Building 1.3s (8/9)
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 753B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 34B 0.0s
=> [internal] load metadata for mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim 0.0s
=> [base 1/2] FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim 0.0s
=> ERROR FROM docker.io/publish/app:latest 1.2s
=> => resolve docker.io/publish/app:latest 1.2s
=> CACHED [base 2/2] WORKDIR /app 0.0s
=> CACHED [final 1/2] WORKDIR /app 0.0s
=> [auth] publish/app:pull token for registry-1.docker.io 0.0s
------
> FROM docker.io/publish/app:latest:
------
failed to load cache key: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed
这是我的 dockerfile:
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /src
COPY ["src/App.Web/App.Web.csproj", "src/App.Web/"]
RUN dotnet restore "App.Web.csproj"
COPY . .
WORKDIR "/src/App.Web"
RUN dotnet build App.Web.csproj -c Debug -o /app
FROM build as debug
RUN dotnet publish "App.Web.csproj" -c Debug -o /app
FROM base as final
WORKDIR /app
COPY --from=publish/app /app .
ENTRYPOINT ["dotnet","App.Web.dll"]
您登录了吗?尝试 docker login
然后再次执行 docker build
正如我在此处看到的那样 aspnet in docker hub 您打算使用的存储库已重命名。请改用以下内容
from mcr.microsoft.com/dotnet/aspnet:3.1-buster-slim
存储库已重命名,可以在此处找到类似的问题
您有称为基础、构建和调试的阶段。那么在最后阶段你有:
COPY --from=publish/app /app .
当 docker 找不到具有该名称 publish/app
的舞台时,它会尝试查找不存在的图像。我猜你想从构建阶段复制,例如
COPY --from=build /app .