docker-registry v2 RESTful如何删除镜像?

  • 先看下官方文档:


docker_2.png


  • 我自己启动registry
    docker run -d -p 5000:5000 --name registry --restart=always -v `pwd`/data:/var/lib/registry registry:2

  • push两个镜像
    curl -X GET localhost:5000/v2/busybox/tags/list
    {"name":"busybox","tags":}

  • 删除restful
    DELETE /v2/<name>/manifests/<reference>



For deletes, reference must be a digest or the delete will fail. If the image exists and has been successfully deleted,
  • busybox的digest
    {{{
    docker pull localhost:5000/busybox
    Using default tag: latest
    latest: Pulling from busybox
Digest: sha256:ea0265569e69ab71f42ccc228499de3c65606ddaf1658f1803679016dffc9271
Status: Image is up to date for localhost:5000/busybox:latest
}}}
  • 我的删除操作


curl -v -X DELETE http://localhost:5000/v2/busybox/manifests/sha256:0fc02bc170932a0d727de2201c65bfe3fe31448dfed6f6bcbc1b37c2668927f5

  • 返回结果

* Hostname was NOT found in DNS cache
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 5000 (#0)
> DELETE /v2/busybox/manifests/sha256:0fc02bc170932a0d727de2201c65bfe3fe31448dfed6f6bcbc1b37c2668927f5 HTTP/1.1
> User-Agent: curl/7.35.0
> Host: localhost:5000
> Accept: */*

< HTTP/1.1 405 Method Not Allowed
< Content-Type: application/json; charset=utf-8
< Docker-Distribution-Api-Version: registry/2.0
< X-Content-Type-Options: nosniff
< Date: Fri, 25 Dec 2015 06:14:55 GMT
< Content-Length: 78

{"errors":}
* Connection #0 to host localhost left intact


返回结果和(https://github.com/docker/dock ... delete)上的讨论似乎还没实现?
已邀请:

beyondblog - 标准90后有为青年

赞同来自:


删除的话至少要添加
REGISTRY_STORAGE_DELETE_ENABLED: true
这个环境变量

gosharplite

赞同来自:


关于删除需要特别关注一件事。
https://github.com/docker/dist ... letes

dxwker - Docker是当前非常热的云计算技术,Docker将APP变成标准化的、可移植的、自管理的组件,在任何主流系统中开发、调试和运行,相比传统的虚拟主机更加灵活,速度更快。另外我是才云Docker工程师,欢迎有问题一起交流!

赞同来自:


加了此环境变量
&amp;amp;lt;pre&amp;amp;gt;REGISTRY_STORAGE_DELETE_ENABLED: true&amp;amp;lt;/pre&amp;amp;gt;

&amp;amp;lt;pre&amp;amp;gt;
curl -X DELETE https://markthink:123456a%40re ... atest

通过接口删除还是报错
code&amp;amp;amp;amp;amp;amp;quot;:&amp;amp;amp;amp;amp;amp;quot;DIGEST_INVALID&amp;amp;amp;amp;amp;amp;quot;,&amp;amp;amp;amp;amp;amp;quot;message&amp;amp;amp;amp;amp;amp;quot;:&amp;amp;amp;amp;amp;amp;quot;provided digest did not match uploaded content&amp;amp;amp;amp;amp;amp;quot;

类似这样的删除并没有删除仓库里的目录文件,暂时还是通过删除目录解决。
curl -v -X DELETE https://markthink:123456a%40re ... 927f5
&amp;amp;lt;/pre&amp;amp;gt;

有解决的吗?

戎码-LiFe

赞同来自:


https://docs.docker.com/regist ... elete 按照这个配置一下,启动删除功能即可
顺便请教一下,我通过api删除manifest和layer后,实际私库中对应的文件还是存在的(感觉是逻辑上的删除),针对这个逻辑删除的猜测,如果有人在知道,请留言

fanne

赞同来自:


我这个为咋无法删除

&amp;amp;lt;pre&amp;amp;gt;

curl -I -X GET http://127.0.0.1:6000/v2/myfir ... atest

HTTP/1.1 200 OK
Content-Length: 5559
Content-Type: application/vnd.docker.distribution.manifest.v1+prettyjws
Docker-Content-Digest: sha256:3a07b4e06c73b2e3924008270c7f3c3c6e3f70d4dbb814ad8bff2697123ca33c
Docker-Distribution-Api-Version: registry/2.0
Etag: &amp;amp;amp;amp;amp;amp;quot;sha256:3a07b4e06c73b2e3924008270c7f3c3c6e3f70d4dbb814ad8bff2697123ca33c&amp;amp;amp;amp;amp;amp;quot;
X-Content-Type-Options: nosniff
Date: Sun, 31 Jul 2016 10:50:11 GMT

curl -X DELETE http://127.0.0.1:6000/v2/myfir ... ca33c

{&amp;amp;amp;amp;amp;amp;quot;errors&amp;amp;amp;amp;amp;amp;quot;:}
&amp;amp;lt;/pre&amp;amp;gt;

henryrao - 一個月內拿下k8s

赞同来自:


这个用脚本删除的
https://github.com/burnettk/de ... image

要回复问题请先登录注册