Repository navigation
Description
Hi,
I'm experiencing an unexpected behaviour when deleting a manifest. I'm doing some experiments in order to understand how to cleanup a local registry thats hosts some images that are build by periodic tasks. The idea was to:
- Create image with tag 1
- Run the container
- Remove image with tag 1 from the registry (= remove the manifest and run garbage collector to remove "dangling" layers)
- Repeat
To validate this strategy I tried to setup a testing environment.
$ docker run -d -p 5000:5000 -e REGISTRY_STORAGE_DELETE_ENABLED=true -v /home/lorenzob/registry:/var/lib/registry --name reg registry:2.5.1
$ docker tag ubuntu:latest localhost:5000/lorenzo/ubuntu:1.0
$ docker push localhost:5000/lorenzo/ubuntu:1.0
$ du -sh registry/
47M registry/At this point I tried to remove the image:
$ curl -I -X HEAD http://localhost:5000/v2/lorenzo/ubuntu/manifests/1.0
HTTP/1.1 200 OK
Content-Length: 9033
Content-Type: application/vnd.docker.distribution.manifest.v1+prettyjws
Docker-Content-Digest: sha256:27f101313deea7d60456d92440dc7e1584b5ef3d9984d5564e588ee3ee760042
Docker-Distribution-Api-Version: registry/2.0
Etag: "sha256:27f101313deea7d60456d92440dc7e1584b5ef3d9984d5564e588ee3ee760042"
X-Content-Type-Options: nosniff
Date: Sat, 03 Dec 2016 16:02:27 GMT
$ curl -X DELETE http://localhost:5000/v2/lorenzo/ubuntu/manifests/sha256:27f101313deea7d60456d92440dc7e1584b5ef3d9984d5564e588ee3ee760042
$ curl -X GET http://localhost:5000/v2/lorenzo/ubuntu/manifests/1.0
{"errors":[{"code":"MANIFEST_UNKNOWN","message":"manifest unknown","detail":{"Tag":"1.0"}}]}
$ du -sh registry/
47M registry/The manifest is gone, the layers are still there. Running the garbage collector does the trick:
$ docker exec reg /bin/registry garbage-collect /etc/docker/registry/config.yml
time="2016-12-03T16:05:13Z" level=info msg="Deleting blob: /docker/registry/v2/blobs/sha256/5b/5ba4f30e5bea63dcc2e7054b8b4f41ab1e5fcc7db0a88fc79359b890bcfe2258" go.version=go1.6.3 instance.id=7320555a-9170-4b25-8d07-425a5cc7d25f
time="2016-12-03T16:05:13Z" level=info msg="Deleting blob: /docker/registry/v2/blobs/sha256/9d/9d7d19c9dc56f51e04f598d8bb8dba1f5cde61434935959ef827ced31f1eb80c" go.version=go1.6.3 instance.id=7320555a-9170-4b25-8d07-425a5cc7d25f
time="2016-12-03T16:05:13Z" level=info msg="Deleting blob: /docker/registry/v2/blobs/sha256/a3/a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4" go.version=go1.6.3 instance.id=7320555a-9170-4b25-8d07-425a5cc7d25f
time="2016-12-03T16:05:13Z" level=info msg="Deleting blob: /docker/registry/v2/blobs/sha256/ac/ac6ad7efd0f97fbaa04d98cbfa6deb994382723ba32b23e46c0ef5b0afcc543e" go.version=go1.6.3 instance.id=7320555a-9170-4b25-8d07-425a5cc7d25f
time="2016-12-03T16:05:13Z" level=info msg="Deleting blob: /docker/registry/v2/blobs/sha256/e7/e7491a747824095463fa464d4d5f7941ff65277012f8102464e9531eb59db7a5" go.version=go1.6.3 instance.id=7320555a-9170-4b25-8d07-425a5cc7d25f
time="2016-12-03T16:05:13Z" level=info msg="Deleting blob: /docker/registry/v2/blobs/sha256/27/27f101313deea7d60456d92440dc7e1584b5ef3d9984d5564e588ee3ee760042" go.version=go1.6.3 instance.id=7320555a-9170-4b25-8d07-425a5cc7d25f
$ du -sh registry/
132K registry/Fine, I thought: it's working! But when I tried to add a new version of the image...
$ docker tag ubuntu:latest localhost:5000/lorenzo/ubuntu:2.0
$ docker push localhost:5000/lorenzo/ubuntu:2.0
$ du -sh registry/
188K registry/What? I was expecting this to be 47MB! The strange thing is that the manifest at http://localhost:5000/v2/lorenzo/ubuntu/manifests/2.0 seems ok, and I can even run a container from that image:
$ docker run --rm localhost:5000/lorenzo/ubuntu:2.0 echo "Hi"
HiAnyway if I try to delete it I receive an error:
$ curl -X DELETE http://localhost:5000/v2/lorenzo/ubuntu/manifests/sha256:27f101313deea7d60456d92440dc7e1584b5ef3d9984d5564e588ee3ee760042
{"errors":[{"code":"MANIFEST_UNKNOWN","message":"manifest unknown"}]}
This looks like a bug to me. Is this related to the fact that I'm actually adding the same image twice with different tags (so the digest is the same)?
Thank you,
lorenzo
PS: I think this has more to do with the registry than with docker itself, but to provide as much informations as I can I'm using docker 1.6.2:
$ docker version
Client version: 1.6.2
Client API version: 1.18
Go version (client): go1.5.1
Git commit (client): 7c8fca2
OS/Arch (client): linux/amd64
Server version: 1.6.2
Server API version: 1.18
Go version (server): go1.5.1
Git commit (server): 7c8fca2
OS/Arch (server): linux/amd64
Activity
stevvooe commentedon Dec 15, 2016
docker run --rm localhost:5000/lorenzo/ubuntu:2.0 echo "Hi"still works because you didn't delete the image locally. If you rundocker rmi localhost:5000/lorenzo/ubuntu:2.0, the image will be removed from the docker instance and it should no longer be pullable.lorenzobenvenuti commentedon Dec 16, 2016
Thank you, it totally makes sense. Anyway, that doesn't explain why after pushing the image
localhost:5000/lorenzo/ubuntu:2.0(which actually has the same digest of the deleted one, being another tag of the same image) the registry size doesn't grow (and, consequently, the error received when I try to delete the manifest from the registry).stevvooe commentedon Dec 20, 2016
@lorenzobenvenuti I see. You did have a push in there. It looks like the the gc isn't cleaning up the references when issuing the deletes.
Could you reproduce the problem then include a the output of
tree registry/after each step?lorenzobenvenuti commentedon Dec 20, 2016
At this point something weird happened: repeating the same steps described in my first comment I wasn't able to delete an image:
Actually this time I did the test using a different VM: the old one was an Ubuntu 14.04 machine, this one is a 16.04. This means different
dockerversions (1.6 vs 1.12) and possibily differentcurlversions.Anyway, after reading this I was able to proceed; don't know why last time I didn't have to use the
Accept:application/vnd.docker.distribution.manifest.v2+jsonheader.It seems that nothing gets actually pushed to the registry; looks like the registry isn't aware of layer removal done by the garbage collector.
At this point, judging from my first post, I was able to retrieve the manifest but not to delete it. This time I cannot even retrieve it.
Hope this helps.
Thank you,
lorenzo
stevvooe commentedon Dec 21, 2016
@lorenzobenvenuti Looks like there is a bug in the gc implementation. The repository still has a bunch of links to blob content.
If you delete
repositories/lorenzo/ubuntu/_layers/sha256/*, does the last push work?@andrewnguyen @dmcgowan PTAL
lorenzobenvenuti commentedon Dec 21, 2016
Removing
repositories/lorenzo/ubuntu/_layers/sha256/*doesn't help; I tried to repeat the above steps on a fresh registry and removed thesha256directory content:Let me know if I can help you further.
lorenzo
ehames commentedon Dec 29, 2016
@lorenzobenvenuti @stevvooe I was working on a cleanup script for one of my deployments and ran into this same issue:
Here is a gist to consistently reproduce it (once this issue is solved the last pull should succeed):
https://gist.github.com/ehames/f904d81d7bc0554c3e602fad3f474808
I have also uploaded the log:
https://gist.github.com/ehames/99bb42ac946d9e97b265cdb9ee30693c
I'm running the latest registry as of today
registry latest 182810e6ba8c 27 hours ago 37.62 MB
siju-vasudevan commentedon Aug 31, 2017
Hello All ,
I also faced similar kind of issue. I am using registry 2.5 backed by swift storage and using redis for caching. Issue occurs when I delete an image manifest digest and do garbage collection then when I try to push the same image to the registry, the push will get complete. But if you try to pull the same image from the registry you will get an error message saying that image not found. If you try to do a curl to get digest information for the same image you will get 404 error.
After lots of debugging and testing found that the issue is with the caching layer or garbage collection is not updating the details in redis cache. After delete when you push the image the manifest digest layer is not getting uploaded to the backed and rest all the layers are getting uploaded.
I logged into redis and checked for the keys . Found that all the keys are present including the deleted digest manifest layer.
Next time i followed the below steps
5 . pulled the image. Success.
Hope this information will be useful for any one of you. Not sure whether GC process can also take care of updating the info in caching layer.
stevvooe commentedon Sep 1, 2017
@siju-vasudevan Thanks for the analysis!
It is very likely that this could be a cache invalidation issue. This would cause the registry to respond with "I have this blob" then have the pusher skip pushing that content.
I've marked this with the 2.7 milestone and will look into a fix when I can. In the meantime, the workaround is to reset the cache after a GC run by clearing redis or restarting the registry, if you are using the inmemory cache.
siju-vasudevan commentedon Sep 1, 2017
HI Stephen,
Thank you!
From my analysis what i have found is that when you push the same image which you deleted registry is contacting redis . From the redis cache the information is not removed hence registry will get the information about the digest(200 ok). If the information is not available in the redis then you will get 404 error unknown blob and then the registry will try to push the digest data layer as well.
Where as when 200 ok is received at that time registry is not pushing the digest manifest data layer but rest all data's are pushed.
Kindly find the details below.
1 . I pushed the hello-world image first and checked the swift backed. Could see 10 objects.

2. After delete and gc process , i pushed the same image and found that one layer is missing, that is digest data layer.
So basically when the registry gets the digest information from the redis, then it is ignoring the digest layer to upload.
In real production environment clearing cache completely is not applicable.
When performing delete operation we need to delete the digest key from the redis.
Thanks,
Siju
stevvooe commentedon Sep 1, 2017
Why not? The performance benefits of the cache here aren't great. Have you seen actual performance problems after clearing the cache?
siju-vasudevan commentedon Sep 6, 2017
Hi Stephan,
We have seen slight performance problems while doing testing, it's not going to have a huge impact.
7 remaining items
Signed-off-by: wangyan <[email protected]>
Signed-off-by: wangyan <[email protected]>
xs233 commentedon Apr 18, 2019
When to fix it?
igcherkaev commentedon Oct 3, 2019
This bug needs to be fixed ASAP.
JakeMoh commentedon Aug 15, 2020
The cache can be removed entirely . This solved my issue

aguidirh commentedon Jul 31, 2024
I am facing the same issue here.
After deleting the images and running the garbage collector, trying to push the same images previously deleted won't work. Restarting the registry or disabling the cache is a temporary workaround I am using so far.
Probably the cache should be updated after deleting/garbage collecting blobs in order to be aligned with the real content in the registry.
binaryfire commentedon Aug 2, 2025
Does anyone know if this has been addressed in v3?
commodis commentedon Nov 16, 2026
I am experiencing the same problem on v3