Home Explore Blog CI



docker

1st chunk of `content/manuals/engine/logging/drivers/gcplogs.md`
f3ad577f94c6bb8a6c7d2f16e268c6bede8198cdb1aa6b4d0000000100000b02
---
description: Learn how to use the Google Cloud Logging driver with Docker Engine
keywords: gcplogs, google, docker, logging, driver
title: Google Cloud Logging driver
aliases:
  - /engine/admin/logging/gcplogs/
  - /config/containers/logging/gcplogs/
---

The Google Cloud Logging driver sends container logs to
[Google Cloud Logging](https://cloud.google.com/logging/docs/)
Logging.

## Usage

To use the `gcplogs` driver as the default logging driver, set the `log-driver`
and `log-opt` keys to appropriate values in the `daemon.json` file, which is
located in `/etc/docker/` on Linux hosts or
`C:\ProgramData\docker\config\daemon.json` on Windows Server. For more about
configuring Docker using `daemon.json`, see
[daemon.json](/reference/cli/dockerd.md#daemon-configuration-file).

The following example sets the log driver to `gcplogs` and sets the
`gcp-meta-name` option.

```json
{
  "log-driver": "gcplogs",
  "log-opts": {
    "gcp-meta-name": "example-instance-12345"
  }
}
```

Restart Docker for the changes to take effect.

You can set the logging driver for a specific container by using the
`--log-driver` option to `docker run`:

```console
$ docker run --log-driver=gcplogs ...
```

If Docker detects that it's running in a Google Cloud Project, it discovers
configuration from the
[instance metadata service](https://cloud.google.com/compute/docs/metadata).
Otherwise, the user must specify
which project to log to using the `--gcp-project` log option and Docker
attempts to obtain credentials from the
[Google Application Default Credential](https://developers.google.com/identity/protocols/application-default-credentials).
The `--gcp-project` flag takes precedence over information discovered from the
metadata server, so a Docker daemon running in a Google Cloud project can be
overridden to log to a different project using `--gcp-project`.

Docker fetches the values for zone, instance name and instance ID from Google
Cloud metadata server. Those values can be provided via options if metadata
server isn't available. They don't override the values from metadata server.

## gcplogs options

You can use the `--log-opt NAME=VALUE` flag to specify these additional Google
Cloud Logging driver options:

| Option          | Required | Description                                                                                                                                                  |
| :-------------- | :------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `gcp-project`   | optional | Which Google Cloud project to log to. Defaults to discovering this value from the Google Cloud metadata server.                                                               |

Title: Using the Google Cloud Logging Driver with Docker
Summary
This document explains how to configure Docker to use the Google Cloud Logging driver for sending container logs to Google Cloud Logging. It covers setting the driver as the default in the daemon.json file or for specific containers using the --log-driver option. It also details how Docker discovers configuration from the instance metadata service or uses the --gcp-project option for specifying the Google Cloud project. The document also lists available options for the Google Cloud Logging driver.