首页 > 解决方案 > 拒绝容器访问 gcloud 凭据

问题描述

我正在尝试在 Google Cloud 上实现将数据从 HL7 转换为 FHIR( https://github.com/GoogleCloudPlatform/healthcare/tree/master/ehr/hl7/message_converter/java )的容器。但是,我无法在我的机器上本地构建容器,以便稍后部署到云中。

当我尝试使用 docker 在本地旋转图像时,发生的错误始终出现在凭据的身份验证部分中:

docker run --network=host -v ~/.config:/root/.config hl7v2_to_fhir_converter 
/healthcare/bin/healthcare --fhirProjectId=<PROJECT_ID> --fhirLocationId=<LOCATION_ID> -- 
fhirDatasetId=<DATASET_ID> --fhirStoreId=<STORE_ID> --pubsubProjectId=<PUBSUB_PROJECT_ID> -- 
pubsubSubscription=<PUBSUB_SUBSCRIPTION_ID> --apiAddrPrefix=<API_ADDR_PREFIX>

我正在使用 Windows,并且已经执行了以下命令来创建凭据:

gcloud auth application-default login

执行上述命令后,凭证保存在:

C:\Users\XXXXXX\AppData\Roaming\gcloud\application_default_credentials.json

该命令-v ~ / .config: /root/.config应该使 docker 在运行映像时能够搜索凭据,但事实并非如此。发生的错误是:

The Application Default Credentials are not available. They are available if running in Google 
Compute Engine. Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined 
pointing to a file defining the credentials. See 
https://developers.google.com/accounts/docs/application-default-credentials for more information.

我把错误放在什么地方?

谢谢,

标签: windowsdockergoogle-cloud-platformgoogle-authenticationgoogle-cloud-sdk

解决方案


容器与系统的其余部分隔离运行,这是它的优势所在,这也是这种打包方法如此受欢迎的原因。

因此,如果您不将环境中的所有配置传递给容器运行时环境,例如 GOOGLE_APPLICATION_CREDENTIALS env var,那么您的环境中的所有配置都是无效的。

为此写了一篇文章。让我知道它是否有帮助,如果没有,我们将讨论阻塞点!


推荐阅读