Visual Studio docker built error with local repository: pull access denied repository does not exist or may require docker login

Viewed 13

First let me point that all of issues related to the error message on SO where either related to misspelled image names or not being logged in to docker repository.

The error message I receive is as follows:

DT1001  Error response from daemon: pull access denied for hangserver1, repository does not exist or may require 'docker login': denied: requested access to the resource is denied
If the error persists, try restarting Docker Desktop.

I try to rebuild containers from Visual Studio docker-compose project. I use Docker Desktop running on Windows and Visual Studio 2022

Docker compose of a Hangfire server is as follows:

#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/runtime:6.0 AS base
WORKDIR /app

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["src/Hangfire.Server/Hangfire.Server.csproj", "src/Hangfire.Server/"]

RUN dotnet restore "src/Hangfire.Server/Hangfire.Server.csproj"
COPY . .
WORKDIR "/src/src/Hangfire.Server"
RUN dotnet build "Hangfire.Server.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "Hangfire.Server.csproj" -c Release -o /app/publish /p:UseAppHost=false

FROM base AS final

WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Hangfire.Server.dll"]

I would like to have two hangserver containers (hang.server1 and hang.server2) created from the same image (hangserver1). One container has build command the other is dependent on the first one.

My docker compose is as follows:

version: '3.4'

services:    
  hang.ui:
    image: hangui
    restart: unless-stopped
    build:
      context: .
      dockerfile: src/Hangfire.UI/Dockerfile
    ports:
      - '5005:80'
    networks:
      - mynetwork

  hang.server1:
    image: hangserver1
    container_name: 'hang.server.1'
    restart: unless-stopped
    build:
      context: .
      dockerfile: src/Hangfire.Server/Dockerfile
    networks:
      - mynetwork
    depends_on:
      - hang.ui  

  hang.server2:
    image: hangserver1
    container_name: 'hang.server.2'
    restart: unless-stopped    
    networks:
      - mynetwork
    depends_on:
      - hang.server1          
      - hang.ui
    
networks:
  mynetwork:
    driver: bridge

The problem is with hand.serever2 container. When I remove it everything builds and works correctly.

0 Answers
Related