Pass google default application credentials in local docker run

落爺英雄遲暮 提交于 2020-08-24 05:36:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!