Docker Community Forums

Share and learn in the Docker community.

Delete repository from v2 private registry


(Riteshpats) #1

I tried deleting images from a private registry
post which the blobs and the manifest of the pushed image gets deleted .

but it leaves behind an empty repository with the tag of the images which it contained .

Steps Followed:

docker push hostname.xxx.yyy.com:1111/hello-world-abc  push the image
The push refers to a repository [hostname.xxx.yyy.com:1111/hello-world-abc] (len: 1)
aef768067415: Pushed
82152269d8b3: Pushed
latest: digest: sha256:c7d713292dd6dc833ef6364cc6c821ce9523883bc97cc24bedbc572343644b68 size: 1937  get the digest value of the pushed image

[root@slc01olq docker]# curl -i -X GET hostname.xxx.yyy.com:1111/v2/hello-world-abc/manifests/latest  get the blobs associated with the image
HTTP/1.1 200 OK
{
“schemaVersion”: 1,
“name”: “hello-world-abc”,
“tag”: “latest”,
“architecture”: “amd64”,
“fsLayers”: [
{
“blobSum”: “sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4”
},
{
“blobSum”: “sha256:4276590986f6a900029d4afb65b0969777f5ff9f70a00f896ec3b7372072381c”

• Delete the manifest and the Blobs::

curl -i -X DELETE hostname.xxx.yyy.com:1111/v2/hello-world-abc/manifests/sha256:c7d713292dd6dc833ef6364cc6c821ce9523883bc97cc24bedbc572343644b68
HTTP/1.1 202 Accepted

curl -i -X DELETE hostname.xxx.yyy.com:1111/v2/hello-world-abc/blobs/sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4
HTTP/1.1 202 Accepted

curl -i -X DELETE hostname.xxx.yyy.com:1111/v2/hello-world-abc/blobs/sha256:4276590986f6a900029d4afb65b0969777f5ff9f70a00f896ec3b7372072381c
HTTP/1.1 202 Accepted

• Try to pull ::

docker pull hostname.xxx.yyy.com:1111/hello-world-abc
Using default tag: latest
Pulling repository hostname.xxx.yyy.com:1111/hello-world-abc
Error: image hello-world-abc:latest not found

• Search the image

docker search hostname.xxx.yyy.com:1111/hello-world-abc
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
hostname.xxx.yyy.com:1111/hello-world-abc:latest 0

curl -i -X GET hostname.xxx.yyy.com:1111/v2/hello-world-abc/tags/list
HTTP/1.1 200 OK

{“name”:“hello-world-abc”,“tags”:[“latest"]}

Problem statement  The image is getting deleted , but an empty repository remins and I want to delete this as the above search returns an o/p :: {“name”:“hello-world-abc”,“tags”:[“latest”]}  but actually the latest tag has been deleted


(Tobias Munk) #2

Any news on this? We’re having the same issue.


(Kkim1975) #3

Any update on this? We also noticed the same behavior.


(Issjohnm) #4

I believe if you run garbage collection,
docker exec dockerregistry_registry_1 bin/registry garbage-collect /etc/docker/registry/config.yml
the tag will then be removed from the list of available tags and appear like:
{"name":"old_repo","tags":null}
I am uncertain how to completely remove the “name” from the registry.


(Issjohnm) #5

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>


(Vladkras) #6

And what should I do next? I deleted manifests, collected garbage, but repo still exists in the list


(Mdebord) #7

Would like to confirm, based on the above replies - the official way to delete the repo from the catalog (AFTER all manifests under it are purged) is to just delete it from disk?

In other words, there is no API call or garbage collection to remove the empty repository entry, it must be deleted manually from disk?


(Rquackenbush) #8

Docker - any word on this? Having to garbage collect / manually delete from the volume is pretty clunky.