Clean Up Your Docker Registry

Delete unused digests of docker images and save space


First, Let’s Get Familiar With the Jargon

Image for post

images, tags, layers, and blobs
"RepoDigests": ["my.docker.registry.com:5000/ubuntu@sha256:74a1b5f5c5d771cf3570fa0f050e0c827538b7fe1873bc88b85d56818df3f2bc"],

Garbage Collector

Method 01: Using registry REST API

curl -v -X DELETE http://registryhost:reigstryport/v2/${docker_image_name}/manifests/${digest}
docker exec registry bin/registry garbage-collect --dry-run /etc/docker/registry/config.yml

Method 02: Deleting in the file system

rm -r <root>/v2/repositories/${name}/_manifests/tags/${tag}/index/sha256/${hash}rm -r <root>/v2/repositories/${name}/_manifests/revisions/sha256/${hash}
docker exec registry bin/registry garbage-collect --dry-run /etc/docker/registry/config.yml