Delete repository from v2 private registry

Let me be more clear. I am uncertain how to remove the repository “name” from the registry via the API. You can manually remove the repository from the registry after removing the last manifest by just deleting it on the registry server.

sudo rm -rf docker/registry/v2/repositories/old_repo/

It will no longer appear in the catalog after that, but I don’t recommend just deleting the repository without first removing all the manifests and running garbage collection.

To get a list of manifests that may still be on the registry, you can run:

docker exec privateregistry_registry_1 bin/registry garbage-collect --dry-run /etc/docker/registry/config.yml | grep 'old_repo: marking manifest' | awk '{print $4}'

This will give you a list of all the manifest IDs on your registry that haven’t been cleaned up yet. If you don’t have a script, you would need to use the delete api to remove them one at a time:
curl -X DELETE -H "Authorization: Basic abcde12345" https://private.registry/v2/old_repo/manifests/sha256:<manifest_id_here>

1 Like