Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The Google Cloud Logging driver for Docker

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.

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"

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

  • docker-ce v18.03
  • docker-compose v1.21.0
  • Ubuntu 17.10
like image 564
Layo Avatar asked Apr 23 '18 14:04

Layo


People also ask

What is the default logging driver for Docker?

As a default, Docker uses the json-file logging driver, which caches container logs as JSON internally.

Does Google Cloud support Docker?

Google Cloud Platform has many tools for working with and running containerized apps using Docker, including managed Kubernetes and serverless container execution.

What is Docker logging?

When an application in a Docker container emits logs, they are sent to the application's stdout and stderr output streams. The container's logging driver can access these streams and send the logs to a file, a log collector running on the host, or a log management service endpoint.

What is GCP cloud logging?

Cloud Logging is a fully managed service that allows you to store, search, analyze, monitor, and alert on logging data and events from Google Cloud and Amazon Web Services. You can collect logging data from over 150 common application components, on-premises systems, and hybrid cloud systems.


1 Answers

google.DefaultTokenSource: google: could not find default credentials. See https://developers.google.com/accounts/docs/application-default-credentials for more information.

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

This is my solution of problem:

On the host machine:

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

Create file:

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

with this content:

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

Restart docker service:

sudo systemctl daemon-reload
sudo systemctl restart docker

Useful links:

  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/
like image 70
breitsmiley Avatar answered Nov 14 '22 21:11

breitsmiley