dockergoogle-cloud-platformdocker-imagedocker-clouddocker-cleanup

GoogleCloudPlatform/gcr-cleaner cannot delete the stale images


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?


Solution

  • 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+)$"