sincecutoff.com
← all changes

Docker local logging driver supports custom attributes

Introduced 2026-05-14 · score 0.90

HOW TO USE IT

When creating a container with Docker Engine 29.5.0 or later, use the `local` logging driver and specify the label, environment, or tag options to include custom log attributes.

docker run -d --name <container> --env=<KEY>=<VALUE> --label=<KEY>=<VALUE> --log-driver=local --log-opt env=<KEY> --log-opt labels=<KEY> --log-opt labels-regex=<REGEX> --log-opt 'tag=<TEMPLATE>' <image>

WHY THIS HELPS

Configure a container to use the local logging driver with custom log attributes.

REQUIREMENTS AND LIMITATIONS

  • Version: 29.5.0
  • --log-driver=local (required): Select the local logging driver.
  • --log-opt labels=<KEY>[,<KEY>...]: Include the named container labels in log attributes. The release note calls this option `label`; the merged example uses `labels`.
  • --log-opt labels-regex=<REGEX>: Include container labels matching the regular expression. The release note calls this option `label-regex`; the merged example uses `labels-regex`.
  • --log-opt env=<KEY>[,<KEY>...]: Include the named container environment variables in log attributes.
  • --log-opt env-regex=<REGEX>: Include environment variables matching the regular expression.
  • --log-opt tag=<TEMPLATE>: Set the log tag using a template; the merged example uses `{{.ID}}`.
  • --env=<KEY>=<VALUE>: Set a container environment variable that can be selected for log attributes.
  • --label=<KEY>=<VALUE>: Set a container label that can be selected for log attributes.
  • Prerequisite: Docker Engine 29.5.0 or later; this support was included in the 29.5.0 release.
  • Docs conflict: The release note names `label` and `label-regex`; the merged PR's runnable example and official Docker logging option documentation use `labels` and `labels-regex`. Use the documented plural spellings.

FIRST-PARTY EVIDENCE

Check the installed version and the source before using it. Entry JSON

Report a problem with this card