Container registry cleanup not working

Problem to solve

I have a self-hosted GitLab instance and can’t get the container registry cleanup to work.

I enabled the container registry, already pushed several images to my repositories and created a cron job to run garbage collection every week. But no images are deleted.

Steps to reproduce

  1. Push about 10 images into a repositories container registry
  2. Setup a cleanup policy to keep the latest 5 images and to cleanup images older than 1 week
  3. Setup garbage collection cron job on the server to run every week
  4. After two weeks there are still 10 images in the container registry

Configuration

Container Registry:

  • enabled
  • registry[‘storage_delete_enabled‘] = true

Cleanup Policy:

Versions

  • Self-managed

Versions

  • GitLab Enterprise Edition v18.1.1-ee

Helpful resources

  1. Reduce container registry storage | GitLab Docs
  2. GitLab container registry administration | GitLab Docs

Asking just to make sure, those 10 images all have the same image name and only differ in their versions, right?

Yes, the images all have the same name and only differ in the image tag. There are currently 10 different image tags uploaded.

Hmm, in my self-hosted instance, the cleanup policies are working fine. That is, the web interface no longer shows any tags that should have been removed. FTR, I am using the GitLab Container Registry that comes bundled in the GitLab Docker image, combined with storage in an S3 bucket. registry['storage_delete_enabled'] is true, the default. I have not (yet) enabled garbage collection so only the tags are removed and image layers remain in the S3 bucket.

The helpful references you listed do include a number of mentions about images not getting cleaned up under certain circumstances, especially if you use other container registry implementations. I can only suggest you check all these mentions to see if you are afflicted by any of them. Sorry this is of little help.