Skip to content

Using localhost registry does not work with containerd image store on Windows #597

@jackhorton

Description

@jackhorton

We need a custom base image for one of our projects, and because the .NET SDK tools don't support pulling from the local docker image store, we run a local registry locally using the official docker registry container. This method was working fine until i had to reinstall docker desktop for unrelated reasons, at which point it started failing with the following error message: Files\dotnet\sdk\8.0.401\Containers\build\Microsoft.NET.Build.Containers.targets(242,5): error CONTAINER1015: Unable to access the repository 'swarm-agent-base' at tag 'latest' in the registry 'localhost:5000'. Please confirm that this name and tag are present in the registry. [D:\edge\es\4\swarm\Swarm.Agent\Swarm.Agent.csproj]. It seems this issue is caused by using the containerd image store on Docker for Windows, because turning that option off makes this scenario work again (I must have had it off before reinstalling docker desktop).

Repro steps:

  1. Create a custom dockerfile based on one of the runtime images. For instance:
    FROM mcr.microsoft.com/dotnet/runtime:8.0-jammy
    RUN apt-get update && apt-get install -y git
    
  2. Build and push this image to a localhost registry:
    docker run --rm --detach --publish 5000:5000 -e REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY=/var/registry -v my-registry-volume:/var/registry --name registry registry:latest
    docker build . -f Dockerfile -t localhost:5000/my-custom-base:latest
    docker push localhost:5000/my-custom-base:latest
    
  3. Instruct your csproj to base off of your localhost image, and only publish when the registry container is running in the background:
    <ContainerBaseImage>localhost:5000/my-custom-base:latest</ContainerBaseImage>
    
  4. dotnet publish --runtime linux-x64 --configuration Release /t:PublishContainer wil work if containerd is not used, but will fail with the above error if it is used.

The setting in question:
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions