适用于Docker的Google Cloud Logging驱动程序 [英] The Google Cloud Logging driver for Docker

查看:84
本文介绍了适用于Docker的Google Cloud Logging驱动程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尽管我已经将env var GOOGLE_APPLICATION_CREDENTIALS 设置为其中的路径/文件,但我仍无法为Docker认证Google云驱动程序 gcplogs .我的服务帐户的JSON凭证是.错误消息如下:

I'm not able to authenticate the google cloud driver gcplogs for Docker despite the fact that I've set the env var GOOGLE_APPLICATION_CREDENTIALS to the path/file where the JSON credentials of my service account is. The error message is the following:

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上使用的配置是:

The configuration I'm using on docker-compose is:

logging:
      driver: gcplogs
      options:
        gcp-project: "gcloud-project-id"
        gcp-meta-name: "prod-helpsec-01"
        labels: "app"

我要运行docker容器的环境是:

The enviroment I'm trying to run the docker container is:

  • 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服务时,我遇到了与上述相同的问题.

I've had the same problem as above when I've run docker services with gcplogs logging driver.

这是我解决问题的方法:

在主机上:

sudo mkdir -p /etc/systemd/system/docker.service.d

创建文件:

/etc/systemd/system/docker.service.d/docker-service-override.conf

/etc/systemd/system/docker.service.d/docker-service-override.conf

具有以下内容:

[Service]
Environment="GOOGLE_APPLICATION_CREDENTIALS=/root/gcp-logging-service-cridentials.json"

重新启动docker服务:

Restart docker service:

sudo systemctl daemon-reload
sudo systemctl restart docker

有用的链接:

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

这篇关于适用于Docker的Google Cloud Logging驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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