Skip to content

Deleted images are not aware by registry serve #4525

Open

Description

@junwha

Description

#2270 This is still a problem in version 2.8.3.

Deleted images do not persist on the registry server after garbage collecting.
However, registry serve thinks the blobs are still in the server and says "layer already exists" on push request,
while it shows manifest error on pull request for the same image.

Reproduce

First, push a sample image into the registry and delete it with the provided API and garbage collector.

# Push an image to the registry
docker push localhost:5000/sample:latest
# Delete the image from the registry
 curl -v -X DELETE "http://$DSLICE_URL/v2/sample/manifests/$(
    curl -I -H "Accept: application/vnd.docker.distribution.manifest.v2+json" "http://$DSLICE_URL/v2/sample/manifests/latest" \
    | awk '$1 == "Docker-Content-Digest:" { print $2 }' \
    | tr -d $'\r' \
    )"
  # Run the garbage collector
  docker exec -it docker-registry /bin/registry garbage-collect /etc/docker/registry/config.yml

Now, the expected behavior is the image blobs and manifests are completely cleared, and registry serve must be aware that the image is not on the registry server.

However, if we push the same image again, it shows the message "Layer already exists", but the blobs of the layers have been already gone by the garbage collector.

docker push localhost:5000/sample:latest

Thus, if we try to pull the image, it shows error response.

docker pull localhost:5000/sample:latest # Error response from daemon: manifest for localhost:5000/sample:latest not found: manifest unknown: manifest unknown

Expected behavior

registry serve must perceive the absence of the layers after their blobs are deleted by the garbage collector.

registry version

2.8.3

Additional Info

No response

Activity

  1. Ollegio commented on Mar 10, 2025

    @Ollegio

    It appears that manifest cache is not cleared when the manifest is actually deleted.

    adding

    if repo.descriptorCache != nil {
    	statter = cache.NewCachedBlobStatter(repo.descriptorCache, statter)
    }
    

    after statter initialization here
    seems to solve the problem

    However, I haven't tested it thoroughly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions