1

When starting the GCE, it automatically pulls and runs the docker image. I can't pass an argument to the docker run command (as far as I know), so I can't pass the argument --log-driver="gcplogs". The 2nd option docker specifies is adjusting the daemon.json file. However, on GCE these changes are not persisted, hence on a reboot this file is the default file.

Am I looking over something? How can I set the log-driver from docker on a google compute engine?

[Edit] I was able to get it working by choosing a container specialized OS, instead of a normal one. Then at the bottom in the management page you can set the following meta-data:

google-logging-enabled: true

https://cloud.google.com/container-optimized-os/docs/how-to/logging#Console

Jasper
  • 302
  • 3
  • 11

1 Answers1

0

You might want to check below docs and other same issues that already answered by the community.

Docs:
Using the Google Cloud Logging driver for Docker
Cloud Logging driver for a single container

  1. After the instance is created, click the SSH button to open a terminal connected to the machine.
  2. To use the Google Cloud logging driver for Docker, specify the --log-driver=gcplogs command-line argument to the docker run command.

Run the following command to start an NGINX container which writes logs to Cloud Logging:

docker run -d \
    --name mysite \
    --log-driver=gcplogs \
    -p 80:80 \
    nginx

Google Cloud Logging driver with Docker Compose
When using Docker Compose, specify a logging driver for each service in the docker-compose.yml configuration file. For example:

version: '3'
services:
  web:
    logging:
      driver: gcplogs
    ...
  database:
    logging:
      driver: gcplogs
    ...

Google Cloud Logging driver

Stackoverflow
GCP logging driver: failed to initialise
The Google Cloud Logging driver for Docker

JM Gelilio
  • 3,482
  • 1
  • 11
  • 23
JaysonM
  • 596
  • 1
  • 10