Error delete image from Docker Registry using API v2

I'm trying to remove images from Docker Registry using API v2 folloving сommand:

curl -k -v -u 'docker:sdf' -X DELETE https://localhost:5000/v2/bkf/ebbg/manifests/1

But I get next error:

> DELETE /v2/bkf/ebbg/manifests/1 HTTP/1.1
> Authorization: Basic ZG9ja2VyOkRrZmxidmJoMjAx==
> User-Agent: curl/7.35.0
> Host: localhost:5000
> Accept: */*
>
< HTTP/1.1 400 Bad Request
< Content-Type: application/json; charset=utf-8
< Docker-Distribution-Api-Version: registry/2.0
< X-Content-Type-Options: nosniff
< Date: Mon, 14 Mar 2016 07:56:13 GMT
< Content-Length: 98
<
{"errors":[{"code":"DIGEST_INVALID","message":"provided digest did not match uploaded content"}]}

Command:

curl -u 'docker:sdf' -X GET https://localhost:5000/v2/_catalog

show

{"repositories":["bkf/ebbg"]}

comand

curl -k -u 'docker:sdf' -X GET https://localhost:5000/v2/bkf/ebbg/tags/list

show

{"name":"bkf/ebbg","tags":["32","1","latest","12","33","34"]}

In what may be a problem or where did I go wrong?

Upvotes: 2

Views: 2969

Answers (2)

Juergen Klasen
Juergen Klasen

Reputation: 829

The answer to your use case probably is delete_docker_registry_image.py I tried it on my registry and obviously it did the trick :) As reading the python source code isn't too complicated, you can get from there what is done when and how - or simply just use it :P

hope it helps ...

Upvotes: 1

Armando Soto
Armando Soto

Reputation: 31

I managed to get this working with deleting a tag but the repository still remains.

The first command you need will get you the digest:

curl -k -v -u 'docker:sdf' -X HEAD -v https://localhost:5000/v2/bkf/ebbg/manifests/1

That will return the in the header the digest you need.

< Docker-Content-Digest: sha256:xxxxxxx

You will then need to make the DELETE call using the digest:

curl -k -v -u 'docker:sdf' -X DELETE -v --header "Accept: application/vnd.docker.distribution.manifest.v2+json" https://localhost:5000/v2/bkf/ebbg/manifests/sha256:xxxxxxx

If successful it will return:

202 Accepted

This does remove the tag but, like I said, the repository still remains. I will need to do some more work on this to figure out why.

Upvotes: 3

Related Questions