0

I am trying to use the gcr-cleaner that recommended by google to clean up my stale images. However, it cannot delete anything as expected even if it returns me it executes successfully.

I have granted the browser, cloud run admin, service account user, and storage admin roles for the service account. Also, the docker configuration is successful as well. i have tried both GitHub action and cloud run, none of them work. Even if I give it a wrong repo name, it will show

Deleting refs older than 2022-10-25T20:08:16Z on 1 repo(s)...

gcr.io/project-id/my-repo
  ✗ no refs were deleted

But there are a bunch of images are older than that timestamp.

Anyone has the same issue before? How should i solve it?

Ryan
  • 3
  • 2

1 Answers1

0

I just had this issue right now, my problem was that without the flag -tag-filter-any it does not delete tagged images, and all images I wanted to delete are tagged. What solved for me was then setting this flag with the regex for my tags:

docker run -v "${HOME}/.config/gcloud:/.config/gcloud" -it us-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner-cli -grace 720h -keep 5 -repo gcr.io/[MY-PROJECT]/[MY-REPO] -tag-filter-any "^(\d+).(\d+).(\d+)$"

  • Yes, I find out I have to add the "-tag-filter-any" to filter out the tagged images. The documentation does not point it out clearly. – Ryan Nov 07 '22 at 06:29