Docker build pull access denied, repository does not exist or may require
Asked Answered
D

2

82

I am trying to generate a Docker Image without using Visual Studio. I am in the project folder and I execute from windows 10 admin command line docker build . I can't figure out how to make this work.

[+] 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

This is my 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"]
Depersonalization answered 29/1, 2021 at 18:54 Comment(1)
Also see this related question if done from GitHub Actions and below answers don't solve your problem.Somato
M
169

You have stages called base, build, and debug. Then in the final stage you have:

COPY --from=publish/app /app .

When docker can't find the stage with that name, publish/app, it tries to find that image, which doesn't exist. I'm guessing you want to copy from the build stage, e.g.

COPY --from=build /app .
Malorie answered 29/1, 2021 at 21:16 Comment(3)
thanks I see it now. I changed the name without understanding what I didDepersonalization
FROM node:16 as builder, I was missing (as builder) . thanksImbecilic
Thanks! I simply forgot to name a stage, the Docker error message was not clear enough, and I ended up hereUnhallowed
T
4

Are you logged in? Try with docker login and then execute docker build once again

As I can see here aspnet in docker hub the repository that you intent to use has been renamed. Use the following instead

from mcr.microsoft.com/dotnet/aspnet:3.1-buster-slim

Repositories have been renamed and a similar issue can be found here similar issue

Towns answered 29/1, 2021 at 19:41 Comment(1)
Thanks for your suggestion. This did not fix the issue, as it states in the link " Updates will continue to be made to supported tags in the old repository locations for backwards compatibility. " But it is valuable knowledge to know there is a new locationDepersonalization

© 2022 - 2024 — McMap. All rights reserved.