大网数据广告活动
服务器运维问答

Easy way to remove a tag from a private Docker registry?

· 52CE 我爱测

I have a private Docker registry, v2.6.0, containing several tagged versions on an image: foo/bar:1 foo/bar:1_keep (same image as 1) foo/bar:2 foo/bar:3 foo/bar:latest (same image as 3) I want to remove a single tag without neces…

问题原文

原帖链接 · Peter Westlake · CC BY-SA 3.0

I have a private Docker registry, v2.6.0, containing several tagged versions on an image:

foo/bar:1
foo/bar:1_keep    (same image as 1)
foo/bar:2
foo/bar:3
foo/bar:latest    (same image as 3)

I want to remove a single tag without necessarily removing the image. So if I remove tag 2, it's okay to remove the image because nothing else refers to it. But if I remove tag 1, only that tag should go, not the image.

That suggests an API request like this:

DELETE http://repo/v2/foo/bar/tags/1

But that gives me a 404. Instead I have to delete the manifest, which means doing all the work of checking that it isn't in use by another tag.

I looked at the source of https://github.com/fraunhoferfokus/deckschrubber and it doesn't appear to trouble itself with checking that it's safe to remove a manuscript. Am I missing something?

Is there a better way of doing this? If not, why not, and is it likely to be fixed?

已采纳解答

原帖链接 · BMitch · CC BY-SA 4.0

There is currently no api to delete a specific tag. Theoretically you could push a new (possibly empty) manifest to an existing tag, and then delete that. Otherwise, you'll want to track all tags and manifests in your cleanup routine to identify what is safe to delete.


Update:

Tag deletion was added to the now 1.0 OCI distribution-spec. With that, pull request (#3427) was approved to distribution/distribution which is the upstream for the registry image. Its got a milestone of the 3.0 release, so this may be a feature that gets added in the future.

I've also been working on regclient which implements both the tag delete API, and falls back to pushing an empty manifest and deleting that. For a CLI, regclient includes regctl which would look like:

regctl tag rm registry:5000/repo:tag

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-09-06)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。