Dockerregistry – 从文件系统中删除清单

我的CI使用一个标签将图像推送到dockerregistry。 我有一个脚本,定期清理旧的unuser图像。 它只是迭代标签内的摘要,并在registryAPI上调用DELETE(遍历registry文件系统上的文件)。

dir="${REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY}/docker/registry/v2/repositories/test/_manifests/tags/5.3/index/sha256/" oldManifests=$(ls -t $dir | tail -n +2 ; done) for hash in $oldManifests do curl -L -X DELETE http://localhost:5000/v2/test/manifests/sha256:$hash done /bin/registry garbage-collect /etc/docker/registry/config.yml 

垃圾收集后,所有的斑点被删除,但不是_manifests / tags / 5.3 / index / sha256 /下的目录。 为什么? 手动删除它是否安全?

是的,手动删除它是安全的。


在你的情况下,标签是版本化的,它不会伤害使用ls -t 。 在“latest”标签的情况下,最好检查.../_manifests/tags/5.3/current/linksha256:前缀被删除)的内容,然后继续,因为你可能会推送一个旧的清单作为新的降级先前推送的图像时“最新”。

我有一个脚本来清除无标记(您的情况)或从registry标记的图像: https : //github.com/ricardobranco777/clean_registry.sh

我不使用API​​,因为它不支持删除标签。