Deletion of images (you can keep 10 last versions, like I do in my CI) is done in three steps:
-
Enable image deletion by setting environment variable
REGISTRY_STORAGE_DELETE_ENABLED: "true"
and passing it to docker-registry -
Run below script (it will delete all images and tags but keep last 10 versions)
registry.py -l user:pass -r https://example.com:5000 –delete –num 10
-
Run garbage collection (you can put it into your daily cron task)
docker-compose -f [path_to_your_docker_compose_file] run registry bin/registry garbage-collect /etc/docker/registry/config.yml
registry.py can be downloaded from the link below, it also allows listing images, tags and layers, as well as deleting a particular image and/or tag.
https://github.com/andrey-pohilko/registry-cli
Before garbage collection my registry folder was 7 Gb, after I ran the above steps it deflated down to 1 Gb.