批处理docker注册表清单删除:如何通过v2 REST API列出清单? [英] Batch docker registry manifest deletion: How to list manifests via v2 REST api?

查看:77
本文介绍了批处理docker注册表清单删除:如何通过v2 REST API列出清单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想远程删除我的私有Docker注册表中的特定清单或所有清单(v2 api),以便有可能由gc收集图像数据.我发现了这个工具,但它仅适用于标记.我决定扩展它.我想列举清单.是否可以获取清单清单?我找不到对此有用的东西.

I would like to delete particular or all manifests in my private docker registry remotely (v2 api) to make it possible images data to be collected by gc. I found this tool, but it only works with tags. I decided to extend it. I would like to enumerate manifests. Is it possible to get manifests list? I can't find something useful on this.

我检查了这些内容,也正在网上搜索,但没有成功.

I checked those and I'm also searching the web, but with no success.

  • https://docs.docker.com/registry/spec/api/
  • https://docs.docker.com/registry/garbage-collection/

-更新-

这两者都会导致404错误(我只是更喜欢使用wget).对于

Either of both results in 404 error of course (I just prefer using wget). For

https://<registry-origin>/v2/gk-backend/tags/list

我得到了预期的{"name":"gk-backend","tags":["latest"]}.当我尝试父亲获取清单时,我有404.我通过使用

I got {"name":"gk-backend","tags":["latest"]} as I expect. When I try father to get the manifest I have 404. I issue the request by using wget like

wget --method=HEAD --header="Accept: application/vnd.docker.distribution.manifest.v2+json" --no-check-certificate --http-user user --http-password pass https://<registry-origin>/v2/wjs-wealth/manifests/gk-backend:latest -O- 

curl也给了我404

curl --header "Accept: application/vnd.docker.distribution.manifest.v2+json" -sI --user user:pass https://<registry-origin>/v2/wjs-wealth/manifests/gk-backend:latest

推荐答案

我有同样的问题.如果将具有相同标签的Docker映像(称为 manifest )推送到Docker注册表v2.0,则新的 manifest 将使用该标签,而旧的一个会删除,而不是不分配标签的存在.

I have the same problem. If the a docker image (called manifest) pushed to Docker registry v2.0 with same tag, new manifest will take the tag and the old one will NOT deleted instead of existed with no tag assigned.

这些旧清单无法在不知道其摘要的情况下从REST API中列出,并且垃圾回收不会删除它们.

Such old manifests cannot list from REST API without knowning their digests, and garbage collection will not delete them.

我发现获取Docker注册表存储库清单清单的一种方法是通过垃圾收集工具.运行docker exec -it registry registry garbage-collect --dry-run /etc/docker/registry/config.yml.此命令将打印所有存储库的所有清单(,包括分配的标记).如:

One way I found to get list of manifests of a docker registry repository is via garbage collection tool. Run docker exec -it registry registry garbage-collect --dry-run /etc/docker/registry/config.yml. This command will print all manifests (including those assigned tag) of all repositories. Such as:

hello-world
hello-world: marking manifest sha256:fea8895f450959fa676bcc1df0611ea93823a735a01205fd8622846041d0c7cf
hello-world: marking blob sha256:03f4658f8b782e12230c1783426bd3bacce651ce582a4ffb6fbbfa2079428ecb
hello-world: marking blob sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4
hello-world: marking configuration sha256:690ed74de00f99a7d00a98a5ad855ac4febd66412be132438f9b8dbd300a937d
ubuntu

4 blobs marked, 0 blobs eligible for deletion

使用 grep 工具,仅过滤掉清单信息就很容易.

With grep tool, it is easy to filter out manifest information only.

然后,您可以调用delete REST API来删除未使用的清单. 注意不要删除已分配标签的清单.

Then you can call delete REST API to delete unused manifests. Take attention not to delete those manifest with tag assigned.

DELETE REST API仅删除清单信息,不会删除blob中的图像数据,因此,在没有--dry-run的情况下再次运行垃圾收集命令以删除未使用的blob:docker exec -it registry registry garbage-collect /etc/docker/registry/config.yml

DELETE REST API only remove manifest information, image data in blob will not delete, so run garbage collection command again without --dry-run to remove unused blob: docker exec -it registry registry garbage-collect /etc/docker/registry/config.yml

这篇关于批处理docker注册表清单删除:如何通过v2 REST API列出清单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆