Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pass google default application credentials in local docker run

Is there a way of passing my local google default application credentials (https://developers.google.com/identity/protocols/application-default-credentials) via docker run?

My usecase:

  • Code running locally on my machine correctly handles default application credentials
  • Code running within docker image on the GCE instance also correctly handles the default application credentials
  • The problem is with "docker run" on my machine. Code running in the docker container do not use host default application credentials.

It would be nice if I could tell "docker run" to pass the host google default application credentials to the docker image.

like image 902
kozikow Avatar asked Aug 14 '16 00:08

kozikow


People also ask

Where are GCP credentials stored?

Your credentials are stored at ~/. config/gcloud .

What is application default credentials Gcloud?

Application Default Credentials (ADC) ADC is a strategy used by Cloud Client Libraries and Google API Client Libraries to automatically find credentials based on the application environment, and use those credentials to authenticate to Google Cloud APIs.


1 Answers

Passing -v ~/.config:/root/.config should make it work. This assumes that your local code uses application default credentials stored by gcloud auth login in ~/.config/gcloud and that the user's home directory in the container is /root.

like image 99
Alexey Alexandrov Avatar answered Sep 19 '22 12:09

Alexey Alexandrov