30

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.

kozikow
  • 321
  • 1
  • 3
  • 5

1 Answers1

42

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.

Alexey Alexandrov
  • 2,951
  • 1
  • 24
  • 24
  • 4
    Works, thanks. For people reading this - you may not need the whole .config, as there are many more configs not related to gcloud there. – kozikow Aug 26 '16 at 14:16
  • 5
    @kozikow is right, ~/.config/gcloud will suffice. I document how to do this on Windows & Linux in this new blog post here: http://blog.ctaggart.com/2016/11/pass-google-application-default.html – Cameron Taggart Nov 28 '16 at 18:57