Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

delete image from docker registry v2

Tags:

docker

the Docker Registry v2 has an API endpoint to delete an image

DELETE /v2/<name>/manifests/<reference>

https://github.com/docker/distribution/blob/master/docs/spec/api.md#deleting-an-image

However the doc says:

For deletes, reference must be a digest or the delete will fail.

Indeed, using a tag does not work and returns a 405 Operation Not Supported

The problem is, there doesn't seem to be any endpoint to get the digest of an image.

The endpoints to list images, and tags only list those.

Trying to get the manifest with

GET /v2/<name>/manifests/<reference>    

using the tag as <reference>I see that a Docker-Content-Digest header is set with a digest which the doc says is

Docker-Content-Digest: Digest of the targeted content for the request.

while the body contains a bunch of blobSum: <digest>

If I try using the Header digest value, with

GET /v2/<name>/manifests/<reference>

and the digest as <reference>, I get a 404.

the digest looks like: sha256:6367f164d92eb69a7f4bf4cab173e6b21398f94984ea1e1d8addc1863f4ed502

and I tried with and without the sha256 prefix. but no luck

So how am I supposed to get the digest of the image I want to delete, to delete it?

like image 674
MrE Avatar asked Aug 05 '16 17:08

MrE


1 Answers

curl -u login:password -H "Accept: application/vnd.docker.distribution.manifest.v2+json" -X GET https://registry.private.com/v2/<name>/manifests/<tag>

json > config > digest

like image 159
Hugues-Antoine Rabany Avatar answered Nov 28 '22 15:11

Hugues-Antoine Rabany