Skip to content

Garbage collector removed all blobs and corrupted the registry #4461

Closed

Description

@mobidyc

Description

In a multi-arch manifests registry I cleaned up using registry garbage-collect /etc/docker/registry/config.yml and registry garbage-collect -m /etc/docker/registry/config.yml commands.

The second command removed almost all blobs in the registry. The manifests are still in place.
The storage decreased from 445G used to 4G, I don't even know if something is still useable.

Reproduce

  1. Start registry version 2.8.3
  2. Create a docker compose file:
services:
  postgres:
    image: ${REGISTRY_URL}/postgres:latest
    build:
      context: ./depends/postgres
      platforms:
      - "linux/amd64"
      - "linux/arm64"
  1. Create the depends/postgres/Dockerfile (Nothing fancy, just fixing the version for testing)
echo 'FROM postgres:10' > depends/postgres/Dockerfile
  1. Setup a multi-arch builder
docker buildx create --name multi-arch-builder --driver=docker-container --platform linux/amd64 --bootstrap ssh://<remote_AMD_host>"
docker buildx create --name multi-arch-builder --driver=docker-container --platform linux/arm64 --bootstrap --append ssh://<remote_ARM_host>"
  1. Push multi-arch manifest multiple times to simulate unused blobs
docker compose build --builder multi-arch-builder --push

echo 'FROM postgres:11' > depends/postgres/Dockerfile
docker compose build --builder multi-arch-builder --push

echo 'FROM postgres:12' > depends/postgres/Dockerfile
docker compose build --builder multi-arch-builder --push
  1. Run the garbage collector
registry garbage-collect /etc/docker/registry/config.yml
registry garbage-collect -m /etc/docker/registry/config.yml

Expected behavior

  1. Unused blobs removal, keeping the referenced ones.
  2. Not corrupting the registry

registry version

# registry --version
registry github.com/docker/distribution 2.8.3

Additional Info

No response

Activity

  1. mobidyc commented on Sep 11, 2024

    @mobidyc
    Author

    Issue maybe related to #3178

    After digging for all the missing blobs, it appears that only multi-platform OCI manifests are impacted and need to be removed from the repositories.
    The manifests with only one platform were not impacted.

  2. AleksandrNull commented on Oct 20, 2024

    @AleksandrNull

    Unfortunately, yes, I have to confirm that cleanup doesn't work with multi-arch manifests which leads to the complete wipe of the all the layers of arch's mentioned in it.

  3. proligde commented on Nov 29, 2024

    @proligde

    I stumbled across this ticket after tracking down the mysterious disappearing of seemingly random images from our registry. Turned out it's the multi arch builds that disappear from our registry after each execution of the garbage-collect housekeeping process.

    Some addition info:

    • we're using the current/latest registry:2 image
    • we're using S3 storage backend
    • we're NOT shutting down the registry while doing housekeeping - in fact we start up a second container with the same backend storage configuration, executing garbage-collect.

    Just for my understanding: Is this an edge case scenario/caused by the fact we're not shutting down the actual registry? Because that seems like a pretty serious side effect/bug of running garbage-collect otherwise and I wonder why there are so few people stumbling across that issue.

  4. milosgajdos commented on Nov 29, 2024

    @milosgajdos
    Member

    I dont know if this issue is fixed in the latest release, but please don't use v2: it hasnt got any updates for years, neither will it get any.

  5. mobidyc commented on Dec 13, 2024

    @mobidyc
    Author

    EDIT: wrong assertion on my side:

    I'm not sure to undertand @milosgajdos , registry:2 continues to receive updates as it points to the latest build in the version 2, and is currently pointing to version 2.8.3.

    I was confused between code version and tag releases.

  6. milosgajdos commented on Dec 13, 2024

    @milosgajdos
    Member

    I'm not sure to undertand @milosgajdos , registry:2 continues to receive updates as it points to the latest build in the version 2, and is currently pointing to version 2.8.3.

    You are confusing yourself and everyone who comes to this thread I'm afraid.

    The last code update v2.8 received was 11 months ago; you can see for yourself https://github.com/distribution/distribution/tree/release/2.8

    As for the images, again, please refrain from confusing folks visiting this thread. Get yourself familiar with the registry official image tags: https://hub.docker.com/_/registry/tags

    latest tag does not mean latest release; it means lateststable release which in this case is v2.8 as v3 has only had alpha, beat and most recently 1st release candidate: those are also available via GitHub Registry https://github.com/distribution/distribution/pkgs/container/distribution

    Finally, we also maintain https://hub.docker.com/r/distribution/distribution/tags

  7. mobidyc commented on Dec 27, 2024

    @mobidyc
    Author

    Thank you for these explanations @milosgajdos, and sorry for the confusion, I will edit my post to not confuse other people.

  8. mobidyc commented on Dec 27, 2024

    @mobidyc
    Author

    As this problem seems unsolved right now,
    do you guys have a method to clean-up multi-platform images ?
    My registry continues to grow and I will soon be out of disk space.

  9. mobidyc commented on Dec 28, 2024

    @mobidyc
    Author

    putting it here for contribution

    #!/bin/bash
    
    # registry:2 garbage collector does not work with multi platform images
    # leading to an out of space error
    # to get space back, we can use this script.
    
    # stop the current registry and change it's default port from 5000 to 5002
    # add another data disk and mount another fresh registry on the port 5000 
    # copy the images from the old registry to the new one
    # when the copy is done, delete the old registry and the old disk
    
    
    export REGISTRY_SRC="127.0.0.1:5002"
    export REGISTRY_DST="127.0.0.1:5000"
    
    source .env
    # from the .env file
    # export REGISTRY_USER=
    # export REGISTRY_PASS=
    
    docker login -u="${REGISTRY_USER}" -p="${REGISTRY_PASS}" $REGISTRY_SRC
    docker login -u="${REGISTRY_USER}" -p="${REGISTRY_PASS}" $REGISTRY_DST
    
    # Get the list of repositories
    repos=$(curl -u "${REGISTRY_USER}:${REGISTRY_PASS}" -k -s -X GET http://$REGISTRY_SRC/v2/_catalog | jq -r '.repositories[]' | sort)
    
    for repo in $repos ; do
        echo "Processing ${repo}"
        tags=$(curl -u "${REGISTRY_USER}:${REGISTRY_PASS}" -k -s -X GET http://$REGISTRY_SRC/v2/${repo}/tags/list |jq -r '.tags[]')
    
        for tag in $tags; do
            echo "Copying ${repo}:${tag}"
            ./regctl image copy $REGISTRY_SRC/${repo}:${tag} $REGISTRY_DST/${repo}:${tag}
        done
    done
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