Advisory: This site contains documentation for the v1.12 release candidate version of Docker Engine. For the Docker Engine v1.11 docs, see https://docs.docker.com/v1.11/. Docker for Mac and Docker for Windows are currently in Beta.
The Google Cloud Logging driver sends container logs to Google Cloud Logging.
You can configure the default logging driver by passing the
option to the Docker daemon:
docker daemon --log-driver=gcplogs
You can set the logging driver for a specific container by using the
--log-driver option to
docker run --log-driver=gcplogs ...
This log driver does not implement a reader so it is incompatible with
If Docker detects that it is running in a Google Cloud Project, it will discover configuration
from the instance metadata service.
Otherwise, the user must specify which project to log to using the
log option and Docker will attempt to obtain credentials from the
Google Application Default Credential.
--gcp-project 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
Google Cloud Project using
You can use the
--log-opt NAME=VALUE flag to specify these additional Google
Cloud Logging driver options:
||optional||Which GCP project to log to. Defaults to discovering this value from the GCE metadata service.|
||optional||Whether to log the command that the container was started with. Defaults to false.|
||optional||Comma-separated list of keys of labels, which should be included in message, if these labels are specified for container.|
||optional||Comma-separated list of keys of environment variables, which should be included in message, if these variables are specified for container.|
If there is collision between
env keys, the value of the
takes precedence. Both options add additional fields to the attributes of a
Below is an example of the logging options required to log to the default logging destination which is discovered by querying the GCE metadata server.
docker run --log-driver=gcplogs \ --log-opt labels=location --log-opt env=TEST --log-opt gcp-log-cmd=true --env "TEST=false" --label location=west your/application
This configuration also directs the driver to include in the payload the label
location, the environment variable
ENV, and the command used to start the