Docker的Google Cloud Logging驱动程序

我无法验证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

最佳答案
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

有用的链接

> https://cloud.google.com/docs/authentication/getting-started
> https://docs.docker.com/config/daemon/systemd
> https://docs.docker.com/config/containers/logging/gcplogs/

相关文章

Docker是什么Docker是 Docker.Inc 公司开源的一个基于 LXC技...
本文为原创,原始地址为:http://www.cnblogs.com/fengzheng...
镜像操作列出镜像:$ sudo docker imagesREPOSITORY TAG IMA...
本文原创,原文地址为:http://www.cnblogs.com/fengzheng/p...
在 Docker 中,如果你修改了一个容器的内容并希望将这些更改...
在Docker中,--privileged 参数给予容器内的进程几乎相同的权...