Home > Blockchain >  ERROR: pull access denied, repository does not exist or may require authorization: server message: i
ERROR: pull access denied, repository does not exist or may require authorization: server message: i

Time:12-22

I am trying to run my first .Net Core Web API(Core 2.2) on Docker in local host. I enabled Docker support(Linux) while creating the project.

Docker File

FROM microsoft/dotnet:2.2-aspnetcore-runtime AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM microsoft/dotnet:2.2-sdk AS build
WORKDIR /src
COPY ["SampleApp/SampleApp.csproj", "SampleApp/"]
RUN dotnet restore "SampleApp/SampleApp.csproj"
COPY . .
WORKDIR "/src/SampleApp"
RUN dotnet build "SampleApp.csproj" -c Release -o /app

FROM build AS publish
RUN dotnet publish "SampleApp.csproj" -c Release -o /app

FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "SampleApp.dll"]

When I try to run the API on Docker from VS, I get the following error

Error   CTP1001 An error occurred while attempting to build Docker image.

and when I looked into the output window

1>------ Build started: Project: SampleApp, Configuration: Debug Any CPU ------
1>SampleApp -> E:\Sandbox\ContainerDeployment\SampleApp\SampleApp\bin\Debug\netcoreapp2.2\SampleApp.dll
1>docker build -f "E:\Sandbox\ContainerDeployment\SampleApp\SampleApp\Dockerfile" -t sampleapp:dev --target base  --label "com.microsoft.created-by=visual-studio" "E:\Sandbox\ContainerDeployment\SampleApp"
1>#1 [internal] load build definition from Dockerfile
1>#1 transferring dockerfile: 32B done
1>#2 [internal] load .dockerignore
1>#2 sha256:0237a52bf01ebc117c468d73e0fc890d42166c17898aa5c4fd0fd96dcaee67e8
1>#1 sha256:bb73acd705ce58a2a5ccfdd8d06dc6e46e04a03a430562efdf99961870d2e178
1>#2 transferring context: 34B done
1>
1>#2 DONE 0.0s
1>
1>#3 sha256:2209054a124f7bc1424fa6735d588f36916bcec272f45a5e3e54f7288e65d73e
1>#3 [internal] load metadata for docker.io/microsoft/dotnet:2.2-aspnetcore-runtime
1>#1 DONE 0.0s
1>#3 ERROR: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed
1>------
1>------
1> > [internal] load metadata for docker.io/microsoft/dotnet:2.2-aspnetcore-runtime:
1>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
1>C:\Users\gopalk\.nuget\packages\microsoft.visualstudio.azure.containers.tools.targets\1.4.10\build\Container.targets(258,5): error CTP1001: An error occurred while attempting to build Docker image.
1>Done building project "SampleApp.csproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

CodePudding user response:

.NET Core version 2.2 is not supported anymore, the current LTS .NET version is 6.0. You can see the existing image versions of ASP.NET Core runtime on docker hub.

Updating .NET version on your machine:

If you are using Visual Studio you can use the Visual Studio Installer to install .NET 6 and all the templates that come with it. Then you should either recreate your project with .NET version 6, or upgrade you existing projects to .NET 6 and then re-generate your dockerfile, You can generate a Dockerfile in Visual Studio by right clicking the project file --> add --> docker support, before these steps you should delete your existing dockerfile.

  • Related