We updated our private docker registry to the official Registry 2.0. This version can now delete docker images identified by a hashtag (see https://docs.docker.com/registry/
Regarding your question:
I would need a method to delete all images from the private registry which are no longer identified by a named tag
A new version of the docker registry in distribution/registry:master has this nice feature! However, you won't be able to trigger it from the API.
Anyway, you will be able to clean all untagged manifests in your registry, meaning that every overwritten tag won't leave old manifests and blobs in the registry. Every "unused" layer will be cleaned by the Registry Garbage Collectior.
You just have to run a docker exec
:
docker exec ${container_id} registry garbage-collect \
/path/to/your/registry/config.yml \
--delete-untagged=true
Looking at this garbage-collect binary help:
Usage:
registry garbage-collect [flags]
Flags:
-m, --delete-untagged=false: delete manifests that are not currently referenced via tag
-d, --dry-run=false: do everything except remove the blobs
-h, --help=false: help for garbage-collect
You can have a look at the github PR. It's been merged and usable with distribution/registry
, tag master
as of 2018-02-23. It supersedes the docker/docker-registry
project with a new API design, focused around security and performance...
I did use this feature today and recovered 89% of registry space (5.7 GB vs. 55 GB). Then I switched back to stable registry.