Docker registry garbage collection
Answer a question
Recently started to use Docker registry as a hub for corporate docker images. After couple of weeks I've found that docker registry had eaten all the disk space :(
We have an automatic deploy for the developers which every time pulls latest master from GIT, then creates docker image and pushes it to our registry. Image name and image tag are always the same. So I've expected the old image to be overwritten by new one at docker registry, but actually all these layers are being collected at .../docker/registry/v2/blobs/sha256/ folder.
Built-in garbage collector did not help: /usr/bin/docker exec registry /bin/registry garbage-collect /etc/docker/registry/config.yml. It simply does not remove unused layers and produces smth.like: 1204 blobs marked, 0 blobs eligible for deletion
We have only 1 docker image at all. But it is being pushed to registry very often. How to keep only latest version of the image?
Registry version is 2.4.0
Answers
To force the garbage collector to remove the untagged images, some manifest files must be removed. I have a script that I have been using in production since Docker Registry 2.4.0 and still works with 2.6.1:
https://github.com/ricardobranco777/clean_registry.sh
EDIT: I rewrote it in Python and created a Docker image: https://github.com/ricardobranco777/clean_registry
更多推荐
所有评论(0)