在本地docker run中传递google默认应用程序凭据 [英] Pass google default application credentials in local docker run

查看:138
本文介绍了在本地docker run中传递google默认应用程序凭据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过我的本地google默认应用程序凭据( https://developers.google.com/identity/protocols/application-default-credentials )通过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?

我的用例:

  • 在我的计算机上本地运行的代码可以正确处理默认的应用程序凭据
  • 在GCE实例上的docker映像中运行的代码也可以正确处理默认的应用程序凭据
  • 问题出在我机器上的"docker run".在Docker容器中运行的代码不使用主机默认应用程序凭据.

如果我能告诉"docker run"将主机google默认应用程序凭据传递给docker镜像,那就太好了.

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

推荐答案

传递-v ~/.config:/root/.config应该可以使它工作.假设您的本地代码使用由gcloud auth login存储在〜/.config/gcloud中的应用程序默认凭据,并且容器中用户的主目录为/root.

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.

这篇关于在本地docker run中传递google默认应用程序凭据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆