无法从文件读取GCS凭据

时间:2019-07-05 08:55:26

标签: google-cloud-platform

我已将我的Google Cloud Platform凭据文件作为卷安装在Docker容器中,并使用docker-compose从该文件创建GOOGLE_APPLICATION_CREDENTIALS环境变量。当我进入docker容器时,文件在那里并且可读且内容正确,但是当我检查环境变量的内容时,将返回以下内容:

docker exec -it -u celery container_name sh
/opt/ori $ $GOOGLE_APPLICATION_CREDENTIALS
/opt/ori/application_default_credentials.json: line 2: type:: not found
/opt/ori/application_default_credentials.json: line 3: project_id:: not found
/opt/ori/application_default_credentials.json: line 4: private_key_id:: not found
/opt/ori/application_default_credentials.json: line 5: private_key:: not found
/opt/ori/application_default_credentials.json: line 6: client_email:: not found
/opt/ori/application_default_credentials.json: line 7: client_id:: not found
/opt/ori/application_default_credentials.json: line 8: auth_uri:: not found
/opt/ori/application_default_credentials.json: line 9: token_uri:: not found
/opt/ori/application_default_credentials.json: line 10: auth_provider_x509_cert_url:: not found
/opt/ori/application_default_credentials.json: line 11: client_x509_cert_url:: not found

很明显,它部分提取了JSON文件,因为它提取了密钥,但是为什么找不到值?

1 个答案:

答案 0 :(得分:0)

此语句/opt/ori $ $GOOGLE_APPLICATION_CREDENTIALS将凭据文件视为可执行文件,并尝试将其作为脚本执行。

此行/opt/ori/application_default_credentials.json: line 2: type:: not found向您显示操作系统找不到要执行的程序type::