Repository navigation
Description
Hello!
We are currently experimenting with using multi-arch images in our infrastructure, as we have a mix of IBM Power and regular AMD64-based machines, and are currently using different tags/repositories to distinguish between the architectures, which is not ideal.
We found that the garbage-collect command with the -m parameter on the registry removes the manifests that enable us to use multi-arch, thus rendering us unable to run garbage collection and keep our registry somewhat clean and space-efficient.
I have compiled the following script which shows the behaviour. Beware that it runs docker system prune --all --volumes:
# Remove old registry, clean slate
docker rm -f registry
docker system prune --all --volumes -f
# Start registry
docker run -d -p 5000:5000 --name registry registry
# Pull AMD64-image
docker pull "docker"
docker tag "docker" "localhost:5000/amd64/docker:latest"
docker push "localhost:5000/amd64/docker:latest"
# ARM-image
docker pull "ppc64le/docker"
docker tag "ppc64le/docker" "localhost:5000/ppc64le/docker:latest"
docker push "localhost:5000/ppc64le/docker:latest"
#Create and push manifest for multi-arch ubuntu
docker manifest create --insecure "localhost:5000/docker:latest" "localhost:5000/amd64/docker:latest" "localhost:5000/ppc64le/docker:latest"
docker manifest push -p "localhost:5000/docker:latest"
# Clear local cache
docker system prune --all -f
# Garbage-collect registry
docker exec registry registry garbage-collect --delete-untagged /etc/docker/registry/config.yml
# Pull multi-arch image
docker pull "localhost:5000/docker:latest"
The last couple of lines of output on my machine is:
Total reclaimed space: 439.4MB
amd64/docker
amd64/docker: marking manifest sha256:5782329618eaf703204c70f61c1697a428275bc8d8e5a58fa324798e78e31937
amd64/docker: marking blob sha256:61d75b305666b5c672c2dc789c526f405402c3d37eb44a77470e9217790b9a41
amd64/docker: marking blob sha256:530afca65e2ea04227630ae746e0c85b2bd1a179379cbf2b6501b49c4cab2ccc
amd64/docker: marking blob sha256:33702c1843d19cf7c37af730bcf50c456ac6456ed789053432b000db75d3bed3
amd64/docker: marking blob sha256:d1c203384d5b9b22606055f5a6708153653df701158a6c04748cb77be8238c9e
amd64/docker: marking blob sha256:146feb07c33136aba6d87c2a8d6882cd4d438d957eaaa8f388f59214f1269bd0
amd64/docker: marking blob sha256:cee6b871713b8386f334ada3f80a6f187b8e9130ce7d69236e34fee9f9d44556
amd64/docker: marking blob sha256:db8946a7c6c2c651e2344e7e9ebb692ff53ae6ab2b108a5f484384e165056beb
amd64/docker: marking blob sha256:649b2db28c4901ee36039690e8086767f9c069ebef2f819f53937774a4b74d6b
amd64/docker: marking blob sha256:e7b044ff4e6b0f04ba45ff9f486263b0741ce55315ac6fb0498aec49a0375ee0
amd64/docker: marking blob sha256:dbd7811a8fce869b1e3e2698db341271fcedfe91a3c90e63b19b243ba4187d91
docker
manifest eligible for deletion: sha256:18d3c182508d401451fe7a0c538dff3686360456b233675b4ddb2371aa9d1608
docker: marking manifest sha256:1abd08c6dc1cea1308a4f3213cdb7d7264548ab21beedbde30aa7eed7f209d2d
docker: marking blob sha256:5782329618eaf703204c70f61c1697a428275bc8d8e5a58fa324798e78e31937
docker: marking blob sha256:18d3c182508d401451fe7a0c538dff3686360456b233675b4ddb2371aa9d1608
manifest eligible for deletion: sha256:5782329618eaf703204c70f61c1697a428275bc8d8e5a58fa324798e78e31937
ppc64le/docker
ppc64le/docker: marking manifest sha256:18d3c182508d401451fe7a0c538dff3686360456b233675b4ddb2371aa9d1608
ppc64le/docker: marking blob sha256:a10903a7995b02bb2bb17f3be3423e93bd2ff6a70618d0d42cfed01639a17ec9
ppc64le/docker: marking blob sha256:d6201b52ea9b908d4d6e950e2a79ded27be48979d6f0f63bd3a57b16b621f188
ppc64le/docker: marking blob sha256:7c5cedde51de1c8ffccd5521fd02fc1efc1cc44ece2d5dccb1e550a65366cd80
ppc64le/docker: marking blob sha256:7ab4b28968b92237adc6438d06c14d4680a3936996176f2cea20d781885af568
ppc64le/docker: marking blob sha256:387f12b774ebb4a88b15e4f754eb9c772618a15230f9c093759496c41f5c6c8f
ppc64le/docker: marking blob sha256:8847e0f1fbcbc029817eb1d930620fd68a65b6bf9dcb73b6d2e96d4e8161ba75
ppc64le/docker: marking blob sha256:b7425929e73f782470c79b835b77e1d923e63be874374d247c1deb271178256f
ppc64le/docker: marking blob sha256:72d865172b780f7e0c045e1d59db4d57be4d6f52d93a27f7d7444edead40260b
time="2022-08-01T13:30:53.876986875Z" level=info msg="deleting manifest: /docker/registry/v2/repositories/docker/_manifests/revisions/sha256/18d3c182508d401451fe7a0c538dff3686360456b233675b4ddb2371aa9d1608" go.version=go1.16.15 instance.id=f87bf88e-d8d2-4dfa-9095-71d90367e1aa service=registry
time="2022-08-01T13:30:53.877150402Z" level=info msg="deleting manifest: /docker/registry/v2/repositories/docker/_manifests/revisions/sha256/5782329618eaf703204c70f61c1697a428275bc8d8e5a58fa324798e78e31937" go.version=go1.16.15 instance.id=f87bf88e-d8d2-4dfa-9095-71d90367e1aa service=registry
21 blobs marked, 0 blobs and 2 manifests eligible for deletion
latest: Pulling from docker
manifest for localhost:5000/docker:latest not found: manifest unknown: manifest unknown
I have confirmed that the issue is present on my workstation, which is running:
docker version:
Client: Docker Engine - Community
Version: 20.10.17
API version: 1.41
Go version: go1.17.11
Git commit: 100c701
Built: Mon Jun 6 23:02:57 2022
OS/Arch: linux/amd64
Context: default
Experimental: true
Server: Docker Engine - Community
Engine:
Version: 20.10.17
API version: 1.41 (minimum version 1.12)
Go version: go1.17.11
Git commit: a89b842
Built: Mon Jun 6 23:01:03 2022
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.6
GitCommit: 10c12954828e7c7c9b6e0ea9b0c02b01407d3ae1
runc:
Version: 1.1.2
GitCommit: v1.1.2-0-ga916309
docker-init:
Version: 0.19.0
GitCommit: de40ad0
docker info:
Client:
Context: default
Debug Mode: false
Plugins:
app: Docker App (Docker Inc., v0.9.1-beta3)
buildx: Docker Buildx (Docker Inc., v0.8.2-docker)
scan: Docker Scan (Docker Inc., v0.17.0)
Server:
Containers: 5
Running: 5
Paused: 0
Stopped: 0
Images: 27
Server Version: 20.10.17
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
userxattr: false
Logging Driver: json-file
Cgroup Driver: systemd
Cgroup Version: 2
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 10c12954828e7c7c9b6e0ea9b0c02b01407d3ae1
runc version: v1.1.2-0-ga916309
init version: de40ad0
Security Options:
apparmor
seccomp
Profile: default
cgroupns
Kernel Version: 5.15.0-41-generic
Operating System: Ubuntu 22.04 LTS
OSType: linux
Architecture: x86_64
CPUs: 12
Total Memory: 31.19GiB
Name: FLPC8286
ID: OF2W:RJAA:ZPBP:WO6M:H4GP:GDZC:R5PE:PARX:O3CO:2BPW:CM4U:KJHB
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
docker exec registry registry --version:
registry github.com/docker/distribution v2.8.1+unknown
Activity
snailchen commentedon Sep 7, 2020
+1
benz0li commentedon Jan 6, 2021
Hi @Newspaperman57, I was facing the same issue. Based on your example: Tagging the images
localhost:5000/myubuntu:latest-amd64andlocalhost:5000/myubuntu:latest-armhfshould resolve it.I also use
garbage-collect -mto keep my registry space-efficient. Including the architecture in the tag name instead of sub repositories solved it in my case.@stevvooe or @dmcgowan may give a proper technical explanation why manifests stored in sub repositories get deleted by
garbage-collect -meven though they are part of a fat manifest in the main repository.❓Related to https://docs.gitlab.com/ce/user/packages/container_registry/#blob-unknown-to-registry-error-when-pushing-a-manifest-list?
deleteriousEffect commentedon Jan 6, 2021
There's a couple of things going on.
Manifests which are part of a manifest list need to be in the same repository as the manifest list. If you tag them in separate repositories, they'll be pushed without a tag to the main repository.
The garbage collector with the
-mflag considers each repository separately: there's no kind of hierarchy. So the untagged manifests in the main repository are unlinked within that repository; however, since they're tagged in another repository they're not actually deleted, only the metadata in the main repository is effected.Newspaperman57 commentedon Jan 7, 2021
Thank you for your answers, and explanation.
I can confirm that tagging the images in the same repository instead, e.g.
localhost:5000/myubuntu:latest-amd64works, and the garbage-collector no longer remove them:I guess this is a "workaround", since i can just retag the images in my registry and put them in the same repository instead of /armhf and /amd64, and then make the manifest from there. I would still consider this a bug, so i will leave it open, but i am no longer affected by the issue.
benz0li commentedon Jan 7, 2021
@deleteriousEffect Far more disturbing is the fact, that manifests built with Docker Buildx (number of
--platform> 1; i.e. resulting in a manifest list) are deleted bygarbage-collect -m.Or is there a sound explanation for that, too?
deleteriousEffect commentedon Jan 7, 2021
@benz0li I'm not familiar with Docker Buildx, but it seems like the same thing is happening on the registry side as I mentioned before if manifest lists are involved.
MatthiasKuehneEllerhold commentedon Nov 30, 2021
The problem @benz0li describes is still happening with docker-registry 2.7.1
Any known fixes?
Our registry has grown by 160 GB in 1 month just by daily builds. That not sustainable... garbage-collect without -m does not cleanup all of the outdated layers...
deleteriousEffect commentedon Nov 30, 2021
@MatthiasKuehneEllerhold during garbage collection, we'd roughly need to:
We've done this already at GitLab, but we made quite a few other changes, so it wouldn't port over directly.
This PR addresses this partially, but this is from before I knew about the complications introduced by buildkit cache images, so the discussion is by now somewhat out of date: #3402
Huimintai commentedon Jul 29, 2022
The problem @benz0li describes is still happening with registry v2.8.1 and I was facing the same issue now.
Is there any known fixes about this problem instead of tag image like image:tag-amd64 workaround.
Huimintai commentedon Aug 1, 2022
Hi @stevvooe for registry image GC,if I can only use
garbage-collectinstead ofgarbage-collect -mto clean my local registry.Because I found usegarbage-collectdoes not delete manifests references.But I don't know what is the difference between this two command.[-]Registry garbage-collect -m removes multi-arch manifests[/-][+]Registry garbage-collect --delete-untagged removes multi-arch manifests[/+]Newspaperman57 commentedon Aug 1, 2022
The
-mparameter is equal to the newer--delete-untaggedparameter. I've updated the question and title to reflect this, and verified that this still happens on the newest versionjeffrson commentedon Nov 28, 2022
I wonder why this bug doesn't get more attention by the maintainers or higher priority (if any all - it's about 2 1/2 year since reporting) for fixing it. In fact, it's critical when working with multi-arch images. From the workaround by @benz0li I simply had tagged my images
'myimage:amd64' and 'myimage:arm64'
before creating 'myimage:latest'. One by one, not multiple platforms at once.
This works until somebody decides to build for another tag. In fact, overwriting 'myimage:amd64' and 'myimage:arm64' for creation of 'myimage:different' invalidates 'myimage:latest' during the next garbage collection.
So those "temporary" tags should be 'myimage:-amd64' and 'myimage:-arm64', respectively.
garbage-collect --delete-untagged removes multi-arch manifests distri…
garbage-collect --delete-untagged removes multi-arch manifests distri…
17 remaining items
Fix garbage-collect with OCI manifest index distribution#3178
Adding @readerx test cases to validate support for manifest list dist…
Fix garbage-collect with OCI manifest index distribution#3178
Adding @readerx test cases to validate support for manifest list dist…
Fix garbage-collect with OCI manifest index distribution#3178
[registry] disable broken gc
[registry] disable broken gc
gabrielmocan commentedon Feb 17, 2025
@MatthiasKuehneEllerhold this seems to be fixed on v3. Last week we had a rc3 release, so we're most likely close to a v3 official release.
MatthiasKuehneEllerhold commentedon Mar 18, 2025
Ive just had a look at our monitoring: we've reenabled "-m" for the GC in may 2024 and it works flawlessly since then. We using the newest "registry:2" image (updated each morning).
joshuakb2 commentedon Mar 20, 2025
Why was this issue closed as completed a year ago when it's still broken in registry 2? Just corrupted my company's docker registry.
I was hoping to find out which version of the registry I should upgrade to to avoid this in the future, but it looks like the answer is that there is no stable version available yet that doesn't have this bug. Is that correct?I guess Matthias is saying 2.8.3 works now, sorry I missed that.
sudo-bmitch commentedon Mar 20, 2025
This issue is closed because #4285 merged into main. The last v2 release was in October 2023, and the fix for this is in the v3 branch (currently at 3.0.0-rc3).
joshuakb2 commentedon Mar 20, 2025
Thanks for clarifying sudo-bmitch!
benz0li commentedon Mar 20, 2025
Originally posted by @milosgajdos in #4461 on Dec 13, 2024
Confusing, indeed.
gabrielmocan commentedon Mar 20, 2025
How's that so?