burnettk / delete-docker-registry-image

If you are running a private v2 docker registry, and you are storing your data on disk, running this script from the machine where the data lives will let you fully delete an image or tag

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Remove unreferenced images

ptman opened this issue · comments

Maybe it is already possible, but it seems to me that only specific images can be deleted. I'd like to remove images that aren't tagged. This would allow me to "garbage collect" the registry.

This deletes a repo, regardless of whether the repo has any tags:

delete_docker_registry_image --image testrepo/awesomeimage

If you are looking to delete images that are hanging out from building images on a certain host (like those you can see by running "docker images"), unrelated to a private registry, this might help.

Do either of these help?

If I repeatedly build myimage:latest with small changes and push each of these to the registry, I can only retrieve the last one, right? docker pull myregistry.com/myimage:latest. But the previous versions of myimage:latest aren't automatically cleaned from the registry backend, or are they? How can I remove all the images that aren't reachable via current tags.

@ptman thanks for the explanation. it made sense, but it took me a while to figure out how to implement it. now if you do this on a repo it should do the thing you describe:

delete_docker_registry_image --image testrepo/awesomeimage --untagged --verbose

there is an automated test that i hope mimics you use case, but feel free to let me know how it goes.

This seems to work. Thank you!