[英]Command To Delete All Image Versions of Artifact Registry Except Latest?
I have a GitHub Action that pushes my image to Artifact Registry.我有一个 GitHub Action 将我的图像推送到 Artifact Registry。 This is the steps that authenticates and then pushes it to my Google Cloud Artifact Registry这是验证然后将其推送到我的 Google Cloud Artifact Registry 的步骤
- name: Configure Docker Client
run: |-
gcloud auth configure-docker --quiet
gcloud auth configure-docker $GOOGLE_ARTIFACT_HOST_URL --quiet
- name: Push Docker Image to Artifact Registry
run: |-
docker tag $IMAGE_NAME:latest $GOOGLE_ARTIFACT_HOST_URL/$PROJECT_ID/images/$IMAGE_NAME:$GIT_TAG
docker push $GOOGLE_ARTIFACT_HOST_URL/$PROJECT_ID/images/$IMAGE_NAME:$GIT_TAG
Where $GIT_TAG is always 'latest' $GIT_TAG 始终是“最新的”
I want to add one more command that then purges all except the latest version.我想再添加一个命令,然后清除除最新版本之外的所有命令。 In this screenshot below, you see theres 2 images在下面的屏幕截图中,您可以看到 2 张图片
I would like to remove the one that was 3 days ago as its not the one with the tag 'latest'.我想删除 3 天前的那个,因为它不是带有“最新”标签的那个。
Is there a terminal command to do this?是否有终端命令来执行此操作?
You may initially check through the filtered list of container images for your specific criteria.您最初可能会根据您的特定条件检查过滤后的容器图像列表。
gcloud artifacts docker images list --include-tags
Once you have the view of the images to be deleted, move to the following.看到要删除的图像后,请转到以下内容。
You may use the following command to delete an Artifact Registry container image.您可以使用以下命令删除 Artifact Registry 容器映像。
gcloud artifacts docker images delete IMAGE [--async] [--delete-tags] [GCLOUD_WIDE_FLAG …]
A valid container image that can be referenced by tag or digest, has the format of一个可以被标签或摘要引用的有效容器镜像,格式为
LOCATION-docker.pkg.dev/PROJECT-ID/REPOSITORY-ID/IMAGE:tag
This command can fail for the following reasons:由于以下原因,此命令可能会失败:
It is always recommended to check and reconfirm any deletion operations so you don't lose any useful artifacts and data items.始终建议检查并重新确认任何删除操作,以免丢失任何有用的工件和数据项。 Also check this helpful document here for Artifacts docker Image Deletion guidelines and some useful information on Managing Images .还可以在此处查看此有用文档,了解Artifacts docker 图像删除指南和有关管理图像的一些有用信息。
As guillaume blaquiere mentioned you may have a look at this link which may help you.正如 guillaume blaquiere 提到的,您可以查看此链接,这可能会对您有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.