问题
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.
回答1:
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.
来源:https://stackoverflow.com/questions/38938216/pass-google-default-application-credentials-in-local-docker-run