0

So I have written a script that supposedly removes image by specified tag. From response, it seems like it did remove it. But its unclear if everything related with it was removed.

I used this code to remove it:

conn.request(
    'DELETE',
    f'/v2/{NAME}/manifests/{TAG}',
    headers={
        'Accept': 'application/vnd.docker.distribution.manifest.v2+json',
        'Authorization': f'Bearer {jwt_token}',
    },
)

If I run it again, I get:

b'{"errors":[{"code":"MANIFEST_UNKNOWN","message":"manifest unknown","detail":"s3aws: Path not found: /docker/registry/v2/repositories/myimage/_manifests/tags/feature_docker-hooks-ala"}]}\n'

And I try docker pull myimage:mytag # mytag is tag I deleted, I get

Error response from daemon: manifest for focusate/base-toc:feature_docker-hooks-ala not found: manifest unknown: manifest unknown

So it looks like it was removed.

But if I go to my hub.docker.com,

I still see it like it was not deleted:

enter image description here

I thought maybe it was cached, but even using browser in incognito mode, it still show up. So I wonder, did I remove image by tag correctly or I left up some things, so data is still showed on registry.

Its kind of clunky if such information is kept forever as I want it to be automatically cleaned up (to only keep relevant images). Maybe there is some garbage collection that is done periodically and I just need to wait?

Andrius
  • 19,658
  • 37
  • 143
  • 243
  • Check that there isn't any other image referring that one, otherwise you will be able to delete the tag but not the image. Also, keep in mind that `latest` image, depending on the registry that you're using, could have both tags, one with the correct `` and other with `latest`. If you want to check a workaround to actually delete the images associated to a tag, check here: https://stackoverflow.com/questions/25436742/how-to-delete-images-from-a-private-docker-registry – Daniel Campos Olivares Nov 15 '21 at 17:21
  • Does this answer your question? [How to delete images from a private docker registry?](https://stackoverflow.com/questions/25436742/how-to-delete-images-from-a-private-docker-registry) – Daniel Campos Olivares Nov 15 '21 at 17:22
  • Not quite. I tried deleting via `digest` (specific hash on image). But I get `405` response, which means method is now allowed. I guess I need to set `REGISTRY_STORAGE_DELETE_ENABLED` on my registry. Though is it possible to do it for official registry? As Im using hub.docker.com. – Andrius Nov 15 '21 at 18:59
  • Check the documentation of the Advanced Image Management if you're using Docker Hub as Registry: https://docs.docker.com/docker-hub/api/latest/#operation/PostNamespacesDeleteImages – Daniel Campos Olivares Nov 16 '21 at 09:44
  • I did, and tried that endpoint too. Still getting `405` error. So the only way to delete it is to not specify `digest`, but specific tag. But I think thats a bug, because docs say that you should not be able to delete by tag and must specify digest. Yet it does allow to delete and then seems to even mess up other images (as it might remove related layers or something). But if I delete it this way, tag is still visible from hub frontend (but can't pull that tag) – Andrius Nov 16 '21 at 09:48
  • I suppose you're receiving a `405` on the last endpoint since the Advanced Image Management is a feature for Pro users, not due to that you are providing `digest` on the Method. Related to the tag, as I mentioned you're not deleting the image but the `tag`, only the tag. Apparently for deleting images you need a Pro account: https://docs.docker.com/docker-hub/image-management/#delete-images – Daniel Campos Olivares Nov 16 '21 at 10:49
  • Not true. First it should return `403` if that would be the case. Second, Im `Pro` user. I also thought maybe only `admin` user can do this (as I was testing with token that has `delete` access). But still same thing even if I use admin user (that has direct access to hub platform). Oh and from hub interface, I can delete any tag I want. So its so silly that they do not allow to delete it via API.. – Andrius Nov 16 '21 at 10:58

0 Answers0