我无法为Docker验证Google云端驱动程序gcplogs
,尽管我已将env var GOOGLE_APPLICATION_CREDENTIALS
设置为我的服务帐户的JSON凭据的路径/文件是。错误消息如下:
ERROR: for oncrm_oncrm_1 Cannot start service oncrm: failed to initialize logging driver: google.DefaultTokenSource: google: could not find default credentials. See https://developers.google.com/accounts/docs/application-default-credentials for more information.
我在docker-compose上使用的配置是:
logging:
driver: gcplogs
options:
gcp-project: "gcloud-project-id"
gcp-meta-name: "prod-helpsec-01"
labels: "app"
我正在尝试运行docker容器的环境是:
docker-ce v18.03
docker-compose v1.21.0
Ubuntu 17.10
答案 0 :(得分:3)
google.DefaultTokenSource: google: could not find default credentials. See https://developers.google.com/accounts/docs/application-default-credentials for more information.
使用 gcplogs 日志记录驱动程序运行docker服务时,我遇到了与上述相同的问题。
这是我解决问题的方法:
在主机上:
sudo mkdir -p /etc/systemd/system/docker.service.d
创建文件:
/etc/systemd/system/docker.service.d/docker-service-override.conf
具有以下内容:
[Service]
Environment="GOOGLE_APPLICATION_CREDENTIALS=/root/gcp-logging-service-cridentials.json"
重新启动docker服务:
sudo systemctl daemon-reload
sudo systemctl restart docker
有用的链接: