我有一个注册表,对于一些图像,与不同的标签重复。这些不同的标签有相同的摘要。这些标签的版本号也在增加-例如:
image:478 (digest: foo)
image:477 (digest: foo)
image:476 (digest: foo)
image:475 (digest: bar)
image:474 (digest: baz)
image:473 (digest: baz)虽然创建这些副本的工具已经修复,但我想清理注册表(尽管节省的空间很小,因为图像是完全相同的)并删除副本。对于每一篇文摘,我只想保留最古老的标签。因此,上述清单将被清理到以下几个方面:
image:476 (digest: foo)
image:475 (digest: bar)
image:473 (digest: baz)我有什么选择来做这样的清理?
发布于 2022-09-26 13:29:31
取决于您的注册中心,您可能不会有标签删除API。充其量,您将有一个清单删除API,它接受摘要,并删除指向该摘要的所有标记。我在雷格中所做的解决方法是首先推送一个唯一的空清单,然后删除新的清单。这样做的脚本如下所示:
repo="registry.example.org/project/name"
last_digest=""
for tag in $(regctl tag ls "${repo}" | sort -r); do
cur_digest="$(regctl image digest "${repo}:${tag}")"
if [ "$last_digest" == "$cur_digest" ]; then
echo "Deleting tag: $tag"
regctl tag rm "${repo}:${tag}"
fi
last_digest="$cur_digest"
done确保在没有tag rm命令的情况下进行测试,并验证正确的标记将被删除。
https://stackoverflow.com/questions/73851241
复制相似问题