Repository navigation
Description
Hi,
I am running a docker registry in mirror mode and even though the documentation states that the mirror should periodically remove old content, the disk usage is just growing. Even running a garbage-collect command doesn't delete anything.
So I looked at some of our images which uses just a single tag (latest) and is forcefully rebuilt every weekend. The repo seems to contain all the builds made since the server was set up:
root@docker-mirror:~# ls -l /srv/docker-mirror/docker/registry/v2/repositories/samepagelabs/debuild/_manifests/tags/
total 4
drwxr-xr-x 4 root root 4096 Jul 25 15:27 latest
root@docker-mirror:~# cat /srv/docker-mirror/docker/registry/v2/repositories/samepagelabs/debuild/_manifests/tags/latest/current/link
sha256:6cd609db8fff28ff3e445fb326dafe745419ab01743a88412474b84004be7216
root@docker-mirror:~# ls -l /srv/docker-mirror/docker/registry/v2/repositories/samepagelabs/debuild/_manifests/tags/latest/index/sha256/
total 60
drwxr-xr-x 2 root root 4096 Aug 15 06:02 055b72b683ad64f8f905eb14d08aa34e454d8153c3bb893286415d6b08489595
drwxr-xr-x 2 root root 4096 Jul 25 15:27 178527a9e52318cd2683f9a938c53fd7bf304ba355eafcb1379a011f7013d265
drwxr-xr-x 2 root root 4096 Sep 21 12:23 201ed34fb2d5e4f8e832fff36e0297ddc3d801f89048c141623958530a308d07
drwxr-xr-x 2 root root 4096 Sep 18 23:49 38482e52778cc7008f9b6e47c657cb04827e0231e6d8212409fbe80b40460270
drwxr-xr-x 2 root root 4096 Aug 29 07:25 50008f7be49dcf01761c5dc7b92b3bdc2eae66f89d8f95599318c7ae0554f44e
drwxr-xr-x 2 root root 4096 Aug 1 05:52 6803f988035a772cb269f79129b6711f651bbd6302ad6c5b9483bc1cbcc98c8d
drwxr-xr-x 2 root root 4096 Sep 25 23:48 6bd01e406e99df1699444a2a3e841d28c8f486ff9cdb8afc05112d9084f05e93
drwxr-xr-x 2 root root 4096 Oct 3 06:44 6cd609db8fff28ff3e445fb326dafe745419ab01743a88412474b84004be7216
drwxr-xr-x 2 root root 4096 Sep 5 06:47 81ccb4aeef5c9606c5ad76b6c7d55bfe3316f36b11705dfac1d3835c588db72a
drwxr-xr-x 2 root root 4096 Aug 22 06:18 9180f131857716a1149be2a7fb8eb2a438c16202d70bfbd092a0e014513133bf
drwxr-xr-x 2 root root 4096 Sep 29 10:50 94b38f2250a85807bd36085e6fc46ed578db9c51b8a1669c08a081b450425099
drwxr-xr-x 2 root root 4096 Aug 8 05:41 a6551cb16e1d4072f4537668176df860e2122723fb21e2f0d6be052dad2ddf36
drwxr-xr-x 2 root root 4096 Oct 2 23:47 ac6c40b569b7f3623bda607193131afef94cbfc8bb39751fc13619f7374c0ab6
drwxr-xr-x 2 root root 4096 Sep 26 09:12 e865a1391e722449ab2791f8180db0ed4dff29a931df4fa03ef635afe84ffc45
drwxr-xr-x 2 root root 4096 Sep 11 23:49 fe61574a5c806441fe65e7aead0ddc12d6b5cd08702489468b35d0911cb57c07
I don't fully understand the data structures but it seems to me that there are untagged manifests - is that correct? I'd expect them to be deleted.
That untagged manifests are accessible via API:
wget --no-check-certificate https://localhost/v2/samepagelabs/debuild/manifests/sha256:201ed34fb2d5e4f8e832fff36e0297ddc3d801f89048c141623958530a308d07 -O-
--2016-10-05 08:57:32-- https://localhost/v2/samepagelabs/debuild/manifests/sha256:201ed34fb2d5e4f8e832fff36e0297ddc3d801f89048c141623958530a308d07
Resolving localhost (localhost)... 127.0.0.1, ::1
Connecting to localhost (localhost)|127.0.0.1|:443... connected.
WARNING: no certificate subject alternative name matches
requested host name 'localhost'.
HTTP request sent, awaiting response... 200 OK
Length: 3028 (3.0K) [application/vnd.docker.distribution.manifest.v2+json]
Saving to: 'STDOUT'
- 0%[ ] 0 --.-KB/s {
"schemaVersion": 2,
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"config": {
"mediaType": "application/vnd.docker.container.image.v1+json",
"size": 5762,
"digest": "sha256:5eee63258bb65a2757bbca610075e39321f7fc5282b23d42e8bfeaf025857f2d"
},
"layers": [
{
"mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip",
"size": 51354569,
"digest": "sha256:2f5fbf61137445d75e8077a9ac5b9b89a2b8eda2dc7486ef42c93da4c5d8760b"
},
{
"mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip",
"size": 91,
"digest": "sha256:c7401fdb26a3fe4000538d6388d9d10ad70893fb19f0945350615e906064303c"
},
.....
}
I've also noticed the scheduler-state.json file and found that all the entries have expiration date - no date is in the past, all dates are spread over the next week which leads me to assumption, that the expiration period is one week (although I was unable to find this in the documentation :-)). This file doesn't contain the untagged manifests, just the one tagged as latest, so my next assumption is that some kind of cleaning is actually happening but doesn't delete files on the disk.
The registry is run via following command:
docker run --name mirror -v /srv/docker-mirror:/var/lib/registry -v /etc/registry/config.yml:/etc/docker/registry/config.yml --rm registry:2
root@docker-mirror:~# docker exec mirror registry --version
registry github.com/docker/distribution v2.5.1
And here's the configuration file:
version: 0.1
log:
fields:
service: registry
storage:
cache:
blobdescriptor: inmemory
filesystem:
rootdirectory: /var/lib/registry
http:
addr: :5000
headers:
X-Content-Type-Options: [nosniff]
health:
storagedriver:
enabled: true
interval: 10s
threshold: 3
proxy:
remoteurl: https://registry-1.docker.io
username: samepageict
password: *****
Activity
RichardScothern commentedon Oct 11, 2016
hi @balous As you discovered, the caching registry will clean up old files after a week.
The scheduler state file lists the repository and its expiration date. Repositories get cleaned up when the expiration date occurs and their entry removed from the state file.
balous commentedon Oct 11, 2016
But it doesn't work - entries are removed from the state file but not from disk.
RichardScothern commentedon Oct 11, 2016
What do your logs show? The cleanup process logs the repositories which are removed and the storage driver will also log the delete operation.
balous commentedon Oct 13, 2016
I've found following lines in /var/log/syslog.7.gz:
There are no logs from docker itself:
On Tuesday, I had to remove all the data as the disk usage dropped below 5% and start over. I'll check it again after current entries start to expire. Meanwhile I enabled persistent systemd journal to retain some info from the docker itself. Should I also enable docker debug mode?
RichardScothern commentedon Oct 13, 2016
I suspect the failure are coming from the registry not being able to remove the blob entries. Do you have delete enabled in your config?
balous commentedon Oct 13, 2016
Do you mean registry's config.yml? No, not explicitly, if it's not enabled by default. The config file is pasted above.
As I remember, I had to enable it on our docker registry server to make garbage collection work but the mirror tutorial (https://github.com/docker/distribution/blob/master/docs/recipes/mirror.md ) doesn't mention this.
RichardScothern commentedon Oct 13, 2016
OK, that will need to be enabled. I will make a PR to mention this in the documentation.
balous commentedon Oct 13, 2016
OK thank you, I'll try.
RichardScothern commentedon Oct 14, 2016
PR submitted to github.com/docker/docker.github.io
KDGundermann commentedon Feb 23, 2018
Even if delete is enabled in the config, the proxy blobstore and manifeststore does not support the delete operation:
https://github.com/docker/distribution/blob/6664ec703991875e14419ff4960921cce7678bab/registry/proxy/proxyblobstore.go#L223-L225
https://github.com/docker/distribution/blob/6664ec703991875e14419ff4960921cce7678bab/registry/proxy/proxymanifeststore.go#L94-L96
so the scheduler can not remove outdated entries !!!!
BTW it would be nice to have a configurable TTL
moshebs commentedon Feb 27, 2018
Same issue here. I guess this is a +1.
prune998 commentedon May 26, 2021
Still opened issue, still unanswered, and I'm also facing a registry cache getting full... It would be great to have a clear statement from the maintainers.
Doc is totally unclear:
uploadpurgingseems to only delete orphans (Upload purging is a background process that periodically removes orphaned files from the upload directories of the registry.)So, how do we make the docker-registry setup as a cache of the (now not free) Dockerhub to release space (by removing the olders cached images) ?
Can we make it remove the LESS used images from the cache ?
Thanks
milosgajdos commentedon May 26, 2021
There is a PR opened for this #3238
We're discussing what should be the right behaviour.
prune998 commentedon May 26, 2021
I'm still unsure of the outcome of it.
Mattes83 commentedon Feb 25, 2022
Same here. Currently the registry cache does not seem to delete anything.
milosgajdos commentedon Feb 25, 2022
there is a PR that attempted t solve this problem, but it never got merged because we first didn't reach a consensus and when we eventually did the author didn't follow up on it #3238
Feel free to read the problem and the patch and open a PR is the best advice I can give at the moment I'm afraid.
Mattes83 commentedon Feb 25, 2022
Maybe something like this? #3597
To be honest I don't get why making the ttl configurable should fix the cleanup. If it does not work for a ttl of 7 days it won't work for any other ttl either I guess.
ashb commentedon Apr 29, 2024
This can be closed now #3880 was merged (though this fix will only work once 3.0 is released, or if people run the alpha.)
milosgajdos commentedon Apr 29, 2024
Closing as per the last comment in this thread.
docs: add github link in header
XenGi commentedon Jul 18, 2025
I'm running 3.0.0 and the issue still persists. Even when the ttl is set to 1h, the size of my underlying bucket never shrinks.
Is this feature still broken? Please reopen.