GoogleCloudPlatform / gcr-cleaner

Delete untagged image refs in Google Container Registry or Artifact Registry
Apache License 2.0
805 stars 112 forks source link

Can't launch gcr-cleaner on local for tests #94

Closed yanis-incepto closed 2 years ago

yanis-incepto commented 2 years ago

TL;DR

Hello, I tried to launch gcr-cleaner on local to test it but then, it says i'm not authentified while i am authentified with gcloud. Does it need another form of authentication ?

Expected behavior

I tried to launch the command docker run -it us-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner-cli -dry-run -repo eu.gcr.io/registry and would suppose to see the plugin working but not.

Observed behavior

It says me i'm not connected and shows this error : failed to setup auther: google: could not find default credentials. See https://developers.google.com/accounts/docs/application-default-credentials for more information.

Debug log output

No response

Additional information

No response

sethvargo commented 2 years ago

Hi @yanis-incepto

gcloud authentication lives on your local system, usually at ~/.config/gcloud. This is where the credentials and authentication reside. When starting a Docker container, that path is not mounted, so you would need to mount it into the container:

docker run -v $HOME/.config/gcloud:/.config/gcloud -it us-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner-cli -dry-run -repo eu.gcr.io/registry
yanis-incepto commented 2 years ago

Thanks you, maybe you should add it to the doc ? You're talking about how to do it locally but it misses the gcloud authentification on your command

yanis-incepto commented 2 years ago

Added a PR to modify the doc : https://github.com/GoogleCloudPlatform/gcr-cleaner/pull/110 Maybe it could help some peoples