Skip to content

Registry garbage-collect --delete-untagged removes multi-arch manifests #3178

Closed

Description

@Newspaperman57

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

  1. snailchen commented on Sep 7, 2020

    @snailchen

    +1

  2. benz0li commented on Jan 6, 2021

    @benz0li

    Hi @Newspaperman57, I was facing the same issue. Based on your example: Tagging the images localhost:5000/myubuntu:latest-amd64 and localhost:5000/myubuntu:latest-armhf should resolve it.

    I also use garbage-collect -m to 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 -m even 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?

  3. deleteriousEffect commented on Jan 6, 2021

    @deleteriousEffect
    Member

    a proper technical explanation why manifests stored in sub repositories get deleted by garbage-collect -m even though they are part of a fat manifest in the main repository.

    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 -m flag 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.

  4. Newspaperman57 commented on Jan 7, 2021

    @Newspaperman57
    Author

    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-amd64 works, and the garbage-collector no longer remove them:

    ~$ docker exec registry registry garbage-collect /etc/docker/registry/config.yml -m
    myubuntu
    myubuntu: marking manifest sha256:98d2cb2c0f074b994ab9ab86de11941cd7032abaa72ae5cc841b8320b11aa908 
    myubuntu: marking blob sha256:fa40ea71de3744021cd17d985edd9ed515a34bd64b94ab74789ccd9a0714fa06
    myubuntu: marking blob sha256:c0442bc8c73ecc155863171762f52680a846f0e3158f31d8954fce1b82e5dd55
    myubuntu: marking blob sha256:2c7902a46d5bc7d218a67af084039be74f70594a42740d6ff840ca99be467493
    myubuntu: marking blob sha256:33c81c82b5030fb111519968e6d1a0b20b784c9a3f9234e5fc4e7e306e87e042
    myubuntu: marking blob sha256:c3806710e71c67c0cc7d045f3112b61ed900055116513235f9b5f24e71791780
    myubuntu: marking blob sha256:c8ef2e8267b7f4d3749b679845dbbf6e8f1c4ed1e08504b1b988aca14391f1ec
    myubuntu: marking manifest sha256:a7fa45fb43d471f4e66c5b53b1b9b0e02f7f1d37a889a41bbe1601fac70cb54e 
    myubuntu: marking blob sha256:2c047404e52d7f17bdac4121a13cd844447b74e13063f8cb8f8b314467feed06
    myubuntu: marking blob sha256:f22ccc0b8772d8e1bcb40f137b373686bc27427a70c0e41dd22b38016e09e7e0
    myubuntu: marking blob sha256:3cf8fb62ba5ffb221a2edb2208741346eb4d2d99a174138e4afbb69ce1fd9966
    myubuntu: marking blob sha256:e80c964ece6a3edf0db1cfc72ae0e6f0699fb776bbfcc92b708fbb945b0b9547
    myubuntu: marking manifest sha256:be934643a5ac35ff69b39de5288fb545ed1860d4c84ee421a5bc229b3c088fc5 
    myubuntu: marking blob sha256:a7fa45fb43d471f4e66c5b53b1b9b0e02f7f1d37a889a41bbe1601fac70cb54e
    myubuntu: marking blob sha256:98d2cb2c0f074b994ab9ab86de11941cd7032abaa72ae5cc841b8320b11aa908
    
    13 blobs marked, 0 blobs and 0 manifests eligible for deletion
    ~$ # Pull multi-arch image
    ~$ docker pull "localhost:5000/myubuntu:latest"
    latest: Pulling from myubuntu
    f22ccc0b8772: Pull complete 
    3cf8fb62ba5f: Pull complete 
    e80c964ece6a: Pull complete 
    Digest: sha256:be934643a5ac35ff69b39de5288fb545ed1860d4c84ee421a5bc229b3c088fc5
    Status: Downloaded newer image for localhost:5000/myubuntu:latest
    localhost:5000/myubuntu:latest
    

    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.

  5. benz0li commented on Jan 7, 2021

    @benz0li

    @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 by garbage-collect -m.

    Or is there a sound explanation for that, too?

  6. deleteriousEffect commented on Jan 7, 2021

    @deleteriousEffect
    Member

    @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.

  7. MatthiasKuehneEllerhold commented on Nov 30, 2021

    @MatthiasKuehneEllerhold

    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...

  8. deleteriousEffect commented on Nov 30, 2021

    @deleteriousEffect
    Member

    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...

    @MatthiasKuehneEllerhold during garbage collection, we'd roughly need to:

    • Add every tagged manifest to a list of referenced manifests
    • Check every tagged manifest to determine if it was a manifest list
    • If it is a manifest list, check those manifest lists to see if they're a buildkit cache image
      • If they're a normal manifest list, we'd need to add the referenced manifests to a list of referenced manifests along with the tagged manifests
      • If they're a buildkit cache image, we need to ensure that we're marking their references as blobs

    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

  9. Huimintai commented on Jul 29, 2022

    @Huimintai

    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.

  10. Huimintai commented on Aug 1, 2022

    @Huimintai

    Hi @stevvooe for registry image GC,if I can only use garbage-collect instead of garbage-collect -mto clean my local registry.Because I found use garbage-collectdoes not delete manifests references.But I don't know what is the difference between this two command.

  11. changed the title [-]Registry garbage-collect -m removes multi-arch manifests[/-] [+]Registry garbage-collect --delete-untagged removes multi-arch manifests[/+] on Aug 1, 2022
  12. Newspaperman57 commented on Aug 1, 2022

    @Newspaperman57
    Author

    Hi @stevvooe for registry image GC,if I can only use garbage-collect instead of garbage-collect -mto clean my local registry.Because I found use garbage-collectdoes not delete manifests references.But I don't know what is the difference between this two command.

    The -m parameter is equal to the newer --delete-untagged parameter. I've updated the question and title to reflect this, and verified that this still happens on the newest version

  13. jeffrson commented on Nov 28, 2022

    @jeffrson

    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.

  14. 17 remaining items

  15. added 4 commits that reference this issue on Apr 14, 2024
  16. gabrielmocan commented on Feb 17, 2025

    @gabrielmocan

    @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.

  17. MatthiasKuehneEllerhold commented on Mar 18, 2025

    @MatthiasKuehneEllerhold

    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).

  18. joshuakb2 commented on Mar 20, 2025

    @joshuakb2

    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.

  19. sudo-bmitch commented on Mar 20, 2025

    @sudo-bmitch
    Contributor

    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).

  20. joshuakb2 commented on Mar 20, 2025

    @joshuakb2

    Thanks for clarifying sudo-bmitch!

  21. benz0li commented on Mar 20, 2025

    @benz0li

    I'm not sure to undertand @milosgajdos , registry:2 continues to receive updates as it points to the latest build in the version 2, and is currently pointing to version 2.8.3.

    You are confusing yourself and everyone who comes to this thread I'm afraid.

    The last code update v2.8 received was 11 months ago; you can see for yourself https://github.com/distribution/distribution/tree/release/2.8

    As for the images, again, please refrain from confusing folks visiting this thread. Get yourself familiar with the registry official image tags: https://hub.docker.com/_/registry/tags

    latest tag does not mean latest release; it means lateststable release which in this case is v2.8 as v3 has only had alpha, beat and most recently 1st release candidate: those are also available via GitHub Registry https://github.com/distribution/distribution/pkgs/container/distribution

    Finally, we also maintain https://hub.docker.com/r/distribution/distribution/tags

    Originally posted by @milosgajdos in #4461 on Dec 13, 2024

    Confusing, indeed.

  22. gabrielmocan commented on Mar 20, 2025

    @gabrielmocan

    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).

    How's that so?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions