是否可以从Google容器注册表中删除推送的图片?
我的意思是没有直接处理Google云端存储目录。
谢谢!
答案 0 :(得分:7)
使用当前的UI及其实现,您只能删除标签,不会删除基础图像。
如果它是Docker V2图像,则可以从命令行使用Docker Registry API删除图像,首先删除标记,然后删除清单。在回复结束时更多关于此事。
如果它是Docker V1映像,则没有#34; docker"删除图像的方法,但您可以删除GCS中的图像。
我们正在实施新功能,使您能够删除V2标签和图像。
使用Docker Registry V2 API从命令行删除V2图像/标签的详细信息:
export REGISTRY=gcr.io
export REPOSITORY=foo/bar
# Next line will dump all the manifests and the tags pointing to the manifests:
curl -u _token:$(gcloud auth print-access-token) https://$REGISTRY/v2/$REPOSITORY/tags/list 2>/dev/null | python -mjson.tool
# You will see output like this:
{
...
"manifest": {
"sha256:2aa676...": {},
"sha256:95de3c...": {
"tag": [
"centos7.0.1406",
"centos8.8",
...
]
},
...
},
"name": "foo/bar",
"tags": [
"centos7.0.1406",
"centos8.8",
...
]
}
# Find the image/manifest you want to delete, first delete all its tags,
# then delete the manifest, by using:
curl -X DELETE -u _token:$(gcloud auth print-access-token) https://$REGISTRY/v2/$REPOSITORY/manifests/xxxx
# where xxxx is the tag or manifest you want to delete
# (yes, you delete tag and manifest using the same REST api)
答案 1 :(得分:7)
正如here所述,您可以使用以下gcloud命令从Google容器注册表中删除图片:
gcloud container images delete IMAGE_NAMES [IMAGE_NAMES …] [GLOBAL-FLAG …]
答案 2 :(得分:6)
现在Google Container Registry migrated to v2,你可以:
删除清单,它会实际删除存储空间中的文件和可用空间(例如Google Cloud Shell使用):
$ export REGISTRY=gcr.io
$ export REPOSITORY=my-registry-name/my-image-name
$ export TOKEN=$(gcloud auth print-access-token)
$ curl -u _token:$TOKEN https://$REGISTRY/v2/$REPOSITORY/tags/list 2>/dev/null | python -m json.tool | grep -Po 'sha256:[^"]*' | xargs -i sh -c "curl -X DELETE -u _token:$TOKEN https://$REGISTRY/v2/$REPOSITORY/manifests/{} 2>/dev/null | python -m json.tool"
注意:它不会删除标签使用的清单。
注意2:Docker Registry升级到v2.1.1后,可以调用GET /v2/_catalog
列出所有图像并在所有图像上运行以上操作以简化此过程。
Google Cloud Web UI现在可以删除图片(请参阅https://stackoverflow.com/a/33791574/167897)
答案 3 :(得分:5)
我为Google开了一张同样问题的门票,他们回复说目前不可能继续关注,因为他们计划很快将其添加到用户界面。
与此同时,您必须使用存储浏览器删除任何要删除的内容。
答案 4 :(得分:1)
检查如何删除图像。
使用CLI
gcloud container images delete [HOSTNAME]/[PROJECT-ID]/[IMAGE]
https://cloud.google.com/container-registry/docs/managing#deleting_images