Setup
To launch the service, just run the docker image in a container:
docker run --detach \
--env REGISTRY_STORAGE_DELETE_ENABLED="true" \
--publish <A FREE PORT IN THE SYSTEM>:5000 \
--name registry \
--restart always \
--volume <LOCAL DIRECTORY>:/var/lib/registry \
registry:2.8
REGISTRY_STORAGE_DELETE_ENABLED="true" allows to delete unused/old images. By default, this is disabled.
Back to top
Registry API
Official documentation here.
I wrapped them up in a sub-function of HadronRiderWWW with a nice UI (the "failed" blobs are the ones the backend couldn't delete because shared with other images):

Querying the registry
You can look the image "catalog" up by issuing:
GET http://<server ip>:<server port>/v2/_catalog
You can get details of an image and its tags by issuing:
GET http://<server ip>:<server port>/v2/<IMAGE NAME>/tags/list
And finally, you can get the tag's details and list of blobs, i.e. the binary snippets that make an image tag up, by issuing:
GET http://<server ip>:<server port>/v2/<IMAGE NAME>/manifests/<IMAGE TAG>
Deleting images
First, you need an image tag's record and then issue:
DELETE http://<server ip>:<server port>/v2/<IMAGE NAME>/blobs/<BLOB CHECKSUM>
for each of the "blobSum" values in the "fsLayers" field of the tag record.
And finally, delete the image tag in 2 steps.
- get the "Docker-Content-Digest" by issuing:
GET http://<server ip>:<server port>/v2/<IMAGE NAME>/manifests/<IMAGE TAG>
with 'Accept'='application/vnd.docker.distribution.manifest.v2+json' in the header
- then with the value of 'Docker-Content-Digest' from the headers of the previous query's response as "image digest":
DELETE http://<server ip>:<server port>/v2/<IMAGE NAME>/manifests/<IMAGE DIGEST>
Note that some blobs maybe shared with other images so an attempt to delete them will return an HTTP error you can safely ignore.
Back to top
Comments