distribution: garbage-collect doesn't release much space
Hello, I am having a private docker registry, and we daily pushed images there, I had an job to run garbage-collect periodically, but I found the disk usage still keep increasing.
For example I have one image which is about 1.8G.
Before running the garbage-collect the disk usage is
/dev/xvdf1 99G 87G 6.7G 93% /var/vcap/store
After running garbage-collect, the disk usage is
/dev/xvdf1 99G 87G 7.2G 93% /var/vcap/store
Which means after deleting the image, it only releases about 0.5G disk space, so what’s the remaining 1.2G about?
The registry version is ./registry github.com/docker/distribution v2.4.1+unknown
When running the garbage-collect I do see below logs like
INFO[0002] Deleting blob: /docker/registry/v2/blobs/sha256/03/032c9cf1156abb7b4874b8e4023cf4914344d563cacae591dcf883035451f9bb environment=registry-0 go.version=go1.7 instance.id=34dac3e9-0a18-4646-8650-15131f0d535a service=registry
INFO[0002] Deleting blob: /docker/registry/v2/blobs/sha256/52/526200adb4e562d78fc42fa8db455f82e7ba7cfbb6ca206b9819b1d8cae1b20c environment=registry-0 go.version=go1.7 instance.id=34dac3e9-0a18-4646-8650-15131f0d535a service=registry
INFO[0002] Deleting blob: /docker/registry/v2/blobs/sha256/56/56652bc41678c3a0c39d71a7b5abfff52424dddcc9b5e10e6ab77f704d54fcdf environment=registry-0 go.version=go1.7 instance.id=34dac3e9-0a18-4646-8650-15131f0d535a service=registry
INFO[0002] Deleting blob: /docker/registry/v2/blobs/sha256/99/99647b2457ff2c14d0021fdda1136803b25d57d008957bdd5a18cd629c5b4e85 environment=registry-0 go.version=go1.7 instance.id=34dac3e9-0a18-4646-8650-15131f0d535a service=registry
INFO[0002] Deleting blob: /docker/registry/v2/blobs/sha256/ce/ce7242dfaaec621f029795149ab0d6cb5467c5dc147680a21c6bda0064bb4a00 environment=registry-0 go.version=go1.7 instance.id=34dac3e9-0a18-4646-8650-15131f0d535a service=registry
INFO[0002] Deleting blob: /docker/registry/v2/blobs/sha256/e3/e3a3b148f89d3c5ec415b0310936ad88afd814b5da2507a8c2e898d779f0174d environment=registry-0 go.version=go1.7 instance.id=34dac3e9-0a18-4646-8650-15131f0d535a service=registry
INFO[0002] Deleting blob: /docker/registry/v2/blobs/sha256/10/103dacd4981428e62a92586e434f31f021a84de6a3906e6cfca9b1f2c8bb77df environment=registry-0 go.version=go1.7 instance.id=34dac3e9-0a18-4646-8650-15131f0d535a service=registry
INFO[0002] Deleting blob: /docker/registry/v2/blobs/sha256/11/116679ed92079caa183bc74a6300b514b29ac5d6a086fbc9a1c3d1fb18d8f0f2 environment=registry-0 go.version=go1.7 instance.id=34dac3e9-0a18-4646-8650-15131f0d535a service=registry
INFO[0002] Deleting blob: /docker/registry/v2/blobs/sha256/17/179bd293d2dfc0c039891e50ac056339f493fcca0b0fb4795fb67ef6ffe86efc environment=registry-0 go.version=go1.7 instance.id=34dac3e9-0a18-4646-8650-15131f0d535a service=registry
INFO[0002] Deleting blob: /docker/registry/v2/blobs/sha256/4f/4f4862a850ac45e9eca81b6dc4ca1cedc91c79e5316f125b4bb4b0b14e47d1af environment=registry-0 go.version=go1.7 instance.id=34dac3e9-0a18-4646-8650-15131f0d535a service=registry
INFO[0002] Deleting blob: /docker/registry/v2/blobs/sha256/89/8910ed079727b2440fe714e973181c624e688d09724b93f3a6576d4f426ff8c1 environment=registry-0 go.version=go1.7 instance.id=34dac3e9-0a18-4646-8650-15131f0d535a service=registry
INFO[0002] Deleting blob: /docker/registry/v2/blobs/sha256/ad/adcaecf0c3a2c74b7d90a9b22ed8be10d2486723e6c4686430ac16381efbebe0 environment=registry-0 go.version=go1.7 instance.id=34dac3e9-0a18-4646-8650-15131f0d535a service=registry
INFO[0002] Deleting blob: /docker/registry/v2/blobs/sha256/b1/b16bf7888d5ffeefad15ec2a811f247e65b6c75d4f79fa21acf14ce187594755 environment=registry-0 go.version=go1.7 instance.id=34dac3e9-0a18-4646-8650-15131f0d535a service=registry
INFO[0002] Deleting blob: /docker/registry/v2/blobs/sha256/d9/d95803f917b8505a6a0a4c98c4f8710381dfa0b1f0c4f372ba20906c5f9c9995 environment=registry-0 go.version=go1.7 instance.id=34dac3e9-0a18-4646-8650-15131f0d535a service=registry
INFO[0002] Deleting blob: /docker/registry/v2/blobs/sha256/18/18aefb43df71fc073c41a04689db8132ca5d803a50e8567ee5fff0297015e564 environment=registry-0 go.version=go1.7 instance.id=34dac3e9-0a18-4646-8650-15131f0d535a service=registry
INFO[0002] Deleting blob: /docker/registry/v2/blobs/sha256/19/1983d3edccb0aead4e3fb3f7e5d8f38e85f8b74b8bcad1981fc3380c2e04478f environment=registry-0 go.version=go1.7 instance.id=34dac3e9-0a18-4646-8650-15131f0d535a service=registry
INFO[0002] Deleting blob: /docker/registry/v2/blobs/sha256/8a/8a13effafcb0396b401a116d0553f2ceeaedf0b934ee838a7c99cafdf9804fa0 environment=registry-0 go.version=go1.7 instance.id=34dac3e9-0a18-4646-8650-15131f0d535a service=registry
INFO[0002] Deleting blob: /docker/registry/v2/blobs/sha256/92/9226016f37365aae77f30e37d47aa9d5934f7a8204eeceeef5704ef0dd9f3dd9 environment=registry-0 go.version=go1.7 instance.id=34dac3e9-0a18-4646-8650-15131f0d535a service=registry
INFO[0002] Deleting blob: /docker/registry/v2/blobs/sha256/b3/b3741efd03d4535eeb167fdd6a7765aeca9dfcbd489a8a631da7177ae9b3ebc4 environment=registry-0 go.version=go1.7 instance.id=34dac3e9-0a18-4646-8650-15131f0d535a service=registry
INFO[0002] Deleting blob: /docker/registry/v2/blobs/sha256/d4/d4e191bd4283c8ddc4cc57d9edf987a5cf773fb59591d993a54802f8ed59467c environment=registry-0 go.version=go1.7 instance.id=34dac3e9-0a18-4646-8650-15131f0d535a service=registry
INFO[0002] Deleting blob: /docker/registry/v2/blobs/sha256/5b/5b6df681cb1f4d11e6d1acf08d7dcfbed4c20bbcfec916f189b0946959332548 environment=registry-0 go.version=go1.7 instance.id=34dac3e9-0a18-4646-8650-15131f0d535a service=registry
INFO[0002] Deleting blob: /docker/registry/v2/blobs/sha256/60/603a6affdfcb6943bc53535db3a3ddf376a1c7d7289c8418827b7e3ebc9a1c67 environment=registry-0 go.version=go1.7 instance.id=34dac3e9-0a18-4646-8650-15131f0d535a service=registry
INFO[0002] Deleting blob: /docker/registry/v2/blobs/sha256/64/64e73dd0f364efef29b9abea57b59003d08b2317a8b1e440b3802db46b5c93dc environment=registry-0 go.version=go1.7 instance.id=34dac3e9-0a18-4646-8650-15131f0d535a service=registry
INFO[0002] Deleting blob: /docker/registry/v2/blobs/sha256/ca/ca0ec1eac59887dc3438fc175fc9330258764d64016fc983d36866119832f7aa environment=registry-0 go.version=go1.7 instance.id=34dac3e9-0a18-4646-8650-15131f0d535a service=registry
Is there any known issue about this?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 31
Ok found it, firstly, we used https instead of http, so it did http://https😕/… . Secondly, I added --insecure in curl, because we use auto-generated certificate for now. We reclaimed ~40GB of space, that’s cool!
Somehow, this procedure should be in the official doc one day, because the workflow of overwriting latest layers in very used in every development environment.
Thank you again.
Hi,
I have now created a bit more sustainable solution for this. Please use/star/ignore as you see fit.
https://github.com/mortensteenrasmussen/docker-registry-manifest-cleanup https://hub.docker.com/r/mortensrasmussen/docker-registry-manifest-cleanup
Hi, it sounds like you might have a lot of untagged manifests. To verify this, could you please run this on your registry server in the
$REGISTRY_DIR/data/docker/registry/v2/repositoriesfolder.It will return the number of manifests you have in your registry that doesn’t have a tag associated.
The command looks cryptic, but it uses the filesystem to check tags vs. manifests and returns the manifests that don’t match any tags. If this number is high, I can help you with a command that can delete them. I’m planning to put it on Github, but I’m still testing/verifying it.
We deployed a cron that executes this script. But we encountered an issue that may be related to this script. How well does this script resist to race condition? The symptoms are:
We couldn’t pull an image. Even rebuilding the image does not fix. We had to delete the image directory (with all tags/revisions) ([RegistryDir]/[RepoName]/[ImageName]) and garbage-collect, then rebuild the image, for the pull to work. I believe some layers was missing because they were removed by the cron script, while another image was being pushed. I also suspect this because our logs showed that a clean and a push was processing at the same time.
Anyone has seen this?
Hi, we have the exact same issue. We followed the procedure the official doc, but end up still having full space. In our case, we have images that has no tag at all, and it still takes lots of space. Only when we delete the hole image (that contains no tag), then we can garbage-collect a lot of space.
Here is the result of the command:
I was suspicious the manifest still has a lots of references to unused layers, even when we delete tags.