错误使用API​​ v2从Docker Registry中删除图像

我正在尝试使用API​​ v2删除Docker Registry中的图像,其中包括:

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

但是我得到了下一个错误:

 > 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"}]} 

命令:

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

显示

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

COMAND

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

显示

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

在什么可能是一个问题或我哪里出错?

我设法得到这个与删除标签的工作,但存储库仍然存在。

你需要的第一个命令会得到摘要:

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

这将返回您需要的摘要标题。

 < Docker-Content-Digest: sha256:xxxxxxx 

您将需要使用摘要进行DELETE调用:

 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 

如果成功,将返回:

202接受

这确实删除了标签,但正如我所说,存储库仍然存在。 我将需要做更多的工作来弄清楚为什么。

你的用例的答案可能是delete_docker_registry_image.py我在我的registry上试过了,显然它做的诀窍:)由于阅读python源代码不是太复杂,你可以从那里得到什么时候和如何做 – 或只需使用它:P

希望能帮助到你 …