<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Docker driver client on Grafana Labs</title><link>https://grafana.com/docs/loki/v3.7.x/send-data/docker-driver/</link><description>Recent content in Docker driver client on Grafana Labs</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="/docs/loki/v3.7.x/send-data/docker-driver/index.xml" rel="self" type="application/rss+xml"/><item><title>Docker driver client configuration</title><link>https://grafana.com/docs/loki/v3.7.x/send-data/docker-driver/configuration/</link><pubDate>Thu, 09 Apr 2026 02:28:18 +0000</pubDate><guid>https://grafana.com/docs/loki/v3.7.x/send-data/docker-driver/configuration/</guid><content><![CDATA[&lt;h1 id=&#34;docker-driver-client-configuration&#34;&gt;Docker driver client configuration&lt;/h1&gt;
&lt;p&gt;The Docker daemon on each machine has a default logging driver and
each container will use the default driver unless configured otherwise.&lt;/p&gt;
&lt;h2 id=&#34;installation&#34;&gt;Installation&lt;/h2&gt;
&lt;p&gt;Before configuring the plugin, &lt;a href=&#34;../&#34;&gt;install or upgrade the Grafana Loki Docker Driver Client&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;change-the-logging-driver-for-a-container&#34;&gt;Change the logging driver for a container&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;docker run&lt;/code&gt; command can be configured to use a different logging driver
than the Docker daemon&amp;rsquo;s default with the &lt;code&gt;--log-driver&lt;/code&gt; flag. Any options that
the logging driver supports can be set using the &lt;code&gt;--log-opt &amp;lt;NAME&amp;gt;=&amp;lt;VALUE&amp;gt;&lt;/code&gt; flag.
&lt;code&gt;--log-opt&lt;/code&gt; can be passed multiple times for each option to be set.&lt;/p&gt;
&lt;p&gt;The following command will start Grafana in a container and send logs to Grafana
Cloud, using a batch size of 400 entries and no more than 5 retries if a send
fails.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;docker run --log-driver=loki \
    --log-opt loki-url=&amp;#34;https://&amp;lt;user_id&amp;gt;:&amp;lt;password&amp;gt;@logs-us-west1.grafana.net/loki/api/v1/push&amp;#34; \
    --log-opt loki-retries=5 \
    --log-opt loki-batch-size=400 \
    grafana/grafana&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;The Loki logging driver still uses the json-log driver in combination with sending logs to Loki, this is mainly useful
to keep the &lt;code&gt;docker logs&lt;/code&gt; command working.
You can adjust file size and rotation using the respective log option &lt;code&gt;max-size&lt;/code&gt; and &lt;code&gt;max-file&lt;/code&gt;. Keep in mind that
default values for these options are not taken from json-log configuration.
You can deactivate this behavior by setting the log option &lt;code&gt;no-file&lt;/code&gt; to true.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;change-the-default-logging-driver&#34;&gt;Change the default logging driver&lt;/h2&gt;
&lt;p&gt;If you want the Loki logging driver to be the default for all containers,
change Docker&amp;rsquo;s &lt;code&gt;daemon.json&lt;/code&gt; file (located in &lt;code&gt;/etc/docker&lt;/code&gt; on Linux) and set
the value of &lt;code&gt;log-driver&lt;/code&gt; to &lt;code&gt;loki&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JSON&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-json&#34;&gt;{
  &amp;#34;debug&amp;#34;: true,
  &amp;#34;log-driver&amp;#34;: &amp;#34;loki&amp;#34;
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Options for the logging driver can also be configured with &lt;code&gt;log-opts&lt;/code&gt; in the
&lt;code&gt;daemon.json&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JSON&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-json&#34;&gt;{
  &amp;#34;debug&amp;#34;: true,
  &amp;#34;log-driver&amp;#34;: &amp;#34;loki&amp;#34;,
  &amp;#34;log-opts&amp;#34;: {
    &amp;#34;loki-url&amp;#34;: &amp;#34;https://&amp;lt;user_id&amp;gt;:&amp;lt;password&amp;gt;@logs-us-west1.grafana.net/loki/api/v1/push&amp;#34;,
    &amp;#34;loki-batch-size&amp;#34;: &amp;#34;400&amp;#34;
  }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;log-opt configuration options in daemon.json must be provided as&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;strings. Boolean and numeric values (such as the value for loki-batch-size in
the example above) must therefore be enclosed in quotes (&lt;code&gt;&amp;quot;&lt;/code&gt;).&lt;/p&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;After changing &lt;code&gt;daemon.json&lt;/code&gt;, restart the Docker daemon for the changes to take
effect. All &lt;strong&gt;newly created&lt;/strong&gt; containers from that host will then send logs to Loki via the driver.&lt;/p&gt;
&lt;h2 id=&#34;configure-the-logging-driver-for-a-swarm-service-or-compose&#34;&gt;Configure the logging driver for a Swarm service or Compose&lt;/h2&gt;
&lt;p&gt;You can also configure the logging driver for
a &lt;a href=&#34;https://docs.docker.com/engine/swarm/how-swarm-mode-works/services/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;swarm service&lt;/a&gt;
directly in your compose file. This also applies for &lt;code&gt;docker-compose&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;YAML&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-yaml&#34;&gt;version: &amp;#34;3.7&amp;#34;
services:
  logger:
    image: grafana/grafana
    logging:
      driver: loki
      options:
        loki-url: &amp;#34;https://&amp;lt;user_id&amp;gt;:&amp;lt;password&amp;gt;@logs-prod-us-central1.grafana.net/loki/api/v1/push&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You can then deploy your stack using:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;docker stack deploy my_stack_name --compose-file docker-compose.yaml&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Or with &lt;code&gt;docker-compose&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;docker-compose -f docker-compose.yaml up&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Once deployed, the Grafana service will send its logs to Loki.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Stack name and service name for each swarm service and project name and service name for each compose service are
automatically discovered and sent as Loki labels, this way you can filter by them in Grafana.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;labels&#34;&gt;Labels&lt;/h2&gt;
&lt;p&gt;Loki can receive a set of labels along with log line. These labels are used to index log entries and query back logs
using &lt;a href=&#34;../../../query/log_queries/#log-stream-selector&#34;&gt;LogQL stream selector&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;By default, the Docker driver will add the following labels to each log line:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;filename&lt;/code&gt;: where the log is written to on disk&lt;/li&gt;
&lt;li&gt;&lt;code&gt;host&lt;/code&gt;: the hostname where the log has been generated&lt;/li&gt;
&lt;li&gt;&lt;code&gt;swarm_stack&lt;/code&gt;, &lt;code&gt;swarm_service&lt;/code&gt;: added when deploying from Docker Swarm.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;compose_project&lt;/code&gt;, &lt;code&gt;compose_service&lt;/code&gt;: added when deploying with Docker Compose.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Custom labels can be added using the &lt;code&gt;loki-external-labels&lt;/code&gt;, &lt;code&gt;loki-pipeline-stages&lt;/code&gt;,
&lt;code&gt;loki-pipeline-stage-file&lt;/code&gt;, &lt;code&gt;labels&lt;/code&gt;, &lt;code&gt;env&lt;/code&gt;, and &lt;code&gt;env-regex&lt;/code&gt; options. See the
next section for all supported options.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;loki-external-labels&lt;/code&gt; have the default value of &lt;code&gt;container_name={{.Name}}&lt;/code&gt;. If you have custom value for
&lt;code&gt;loki-external-labels&lt;/code&gt; then that will replace the default value, meaning you won&amp;rsquo;t have &lt;code&gt;container_name&lt;/code&gt; label unless
you explcity add it (e.g: &lt;code&gt;loki-external-labels: &amp;quot;job=docker,container_name={{.Name}}&amp;quot;&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&#34;pipeline-stages&#34;&gt;Pipeline stages&lt;/h2&gt;
&lt;p&gt;While you can provide &lt;code&gt;loki-pipeline-stage-file&lt;/code&gt; it can be hard to mount the configuration file to the driver root
filesystem.
This is why another option &lt;code&gt;loki-pipeline-stages&lt;/code&gt; is available allowing you to pass a list of stages inlined. Pipeline
stages are run at last on every lines.&lt;/p&gt;
&lt;p&gt;The example &lt;a href=&#34;https://github.com/grafana/loki/blob/main/clients/cmd/docker-driver/docker-compose.yaml&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;docker-compose&lt;/a&gt;
below configures 2 stages, one to extract level values and one to set it as a label:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;YAML&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-yaml&#34;&gt;version: &amp;#34;3&amp;#34;
services:
  grafana:
    image: grafana/grafana
    logging:
      driver: loki
      options:
        loki-url: http://host.docker.internal:3100/loki/api/v1/push
        loki-pipeline-stages: |
          - regex:
              expression: &amp;#39;(level|lvl|severity)=(?P&amp;lt;level&amp;gt;\w&amp;#43;)&amp;#39;
          - labels:
              level:
    ports:
      - &amp;#34;3000:3000&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Note the &lt;code&gt;loki-pipeline-stages: |&lt;/code&gt; letting you keep the indentation correct.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;When using docker run you can also pass the value via a string parameter like such:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;read -d &amp;#39;&amp;#39; stages &amp;lt;&amp;lt; EOF
- regex:
     expression: &amp;#39;(level|lvl|severity)=(?P&amp;lt;level&amp;gt;\\\w&amp;#43;)&amp;#39;
- labels:
    level:
EOF

docker run --log-driver=loki \
    --log-opt loki-url=&amp;#34;http://host.docker.internal:3100/loki/api/v1/push&amp;#34; \
    --log-opt loki-pipeline-stages=&amp;#34;$stages&amp;#34; \
    -p 3000:3000 grafana/grafana&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This is a bit more difficult as you need to properly escape bash special characters. (note &lt;code&gt;\\\w&#43;&lt;/code&gt; for &lt;code&gt;\w&#43;&lt;/code&gt;)&lt;/p&gt;
&lt;p&gt;Providing both &lt;code&gt;loki-pipeline-stage-file&lt;/code&gt; and &lt;code&gt;loki-pipeline-stages&lt;/code&gt; will cause an error.&lt;/p&gt;
&lt;h2 id=&#34;relabeling&#34;&gt;Relabeling&lt;/h2&gt;
&lt;p&gt;You can use &lt;a href=&#34;https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Prometheus relabeling&lt;/a&gt; configuration to modify labels discovered by the driver. The configuration must be passed as a YAML string like the &lt;a href=&#34;#pipeline-stages&#34;&gt;pipeline stages&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Relabeling phase will happen only once per container and it is applied on the container metadata when it starts. So you can for example rename the labels that are only available during the starting of the container, not the labels available on log lines. Use &lt;a href=&#34;#pipeline-stages&#34;&gt;pipeline stages&lt;/a&gt; instead.&lt;/p&gt;
&lt;p&gt;For example the configuration below will rename the label &lt;code&gt;swarm_stack&lt;/code&gt; and &lt;code&gt;swarm_service&lt;/code&gt; to respectively &lt;code&gt;namespace&lt;/code&gt; and &lt;code&gt;service&lt;/code&gt;.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;YAML&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-yaml&#34;&gt;version: &amp;#34;3&amp;#34;
services:
  grafana:
    image: grafana/grafana
    logging:
      driver: loki
      options:
        loki-url: http://host.docker.internal:3100/loki/api/v1/push
        loki-relabel-config: |
          - action: labelmap
            regex: swarm_stack
            replacement: namespace
          - action: labelmap
            regex: swarm_(service)
    ports:
      - &amp;#34;3000:3000&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;supported-log-opt-options&#34;&gt;Supported log-opt options&lt;/h2&gt;
&lt;p&gt;To specify additional logging driver options, you can use the &amp;ndash;log-opt NAME=VALUE flag.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Option&lt;/th&gt;
              &lt;th style=&#34;text-align: center&#34;&gt;Required?&lt;/th&gt;
              &lt;th style=&#34;text-align: center&#34;&gt;Default Value&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;loki-url&lt;/code&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;Yes&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
              &lt;td&gt;Loki HTTP push endpoint.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;loki-external-labels&lt;/code&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;No&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;&lt;code&gt;container_name={{.Name}}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Additional label value pair separated by &lt;code&gt;,&lt;/code&gt; to send with logs. The value is expanded with the &lt;a href=&#34;https://docs.docker.com/config/containers/logging/log_tags/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Docker tag template format&lt;/a&gt;. (eg: &lt;code&gt;container_name={{.ID}}.{{.Name}},cluster=prod&lt;/code&gt;)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;loki-timeout&lt;/code&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;No&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;&lt;code&gt;10s&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The timeout to use when sending logs to the Loki instance. Valid time units are &amp;ldquo;ns&amp;rdquo;, &amp;ldquo;us&amp;rdquo; (or &amp;ldquo;µs&amp;rdquo;), &amp;ldquo;ms&amp;rdquo;, &amp;ldquo;s&amp;rdquo;, &amp;ldquo;m&amp;rdquo;, &amp;ldquo;h&amp;rdquo;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;loki-batch-wait&lt;/code&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;No&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;&lt;code&gt;1s&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The amount of time to wait before sending a log batch complete or not. Valid time units are &amp;ldquo;ns&amp;rdquo;, &amp;ldquo;us&amp;rdquo; (or &amp;ldquo;µs&amp;rdquo;), &amp;ldquo;ms&amp;rdquo;, &amp;ldquo;s&amp;rdquo;, &amp;ldquo;m&amp;rdquo;, &amp;ldquo;h&amp;rdquo;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;loki-batch-size&lt;/code&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;No&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;&lt;code&gt;1048576&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The maximum size of a log batch to send.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;loki-min-backoff&lt;/code&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;No&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;&lt;code&gt;500ms&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The minimum amount of time to wait before retrying a batch. Valid time units are &amp;ldquo;ns&amp;rdquo;, &amp;ldquo;us&amp;rdquo; (or &amp;ldquo;µs&amp;rdquo;), &amp;ldquo;ms&amp;rdquo;, &amp;ldquo;s&amp;rdquo;, &amp;ldquo;m&amp;rdquo;, &amp;ldquo;h&amp;rdquo;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;loki-max-backoff&lt;/code&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;No&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;&lt;code&gt;5m&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The maximum amount of time to wait before retrying a batch. Valid time units are &amp;ldquo;ns&amp;rdquo;, &amp;ldquo;us&amp;rdquo; (or &amp;ldquo;µs&amp;rdquo;), &amp;ldquo;ms&amp;rdquo;, &amp;ldquo;s&amp;rdquo;, &amp;ldquo;m&amp;rdquo;, &amp;ldquo;h&amp;rdquo;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;loki-retries&lt;/code&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;No&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;&lt;code&gt;10&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The maximum amount of retries for a log batch. Setting it to &lt;code&gt;0&lt;/code&gt; will retry indefinitely.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;loki-pipeline-stage-file&lt;/code&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;No&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
              &lt;td&gt;The location of a pipeline stage configuration file (&lt;a href=&#34;https://github.com/grafana/loki/blob/main/clients/cmd/docker-driver/pipeline-example.yaml&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;example&lt;/a&gt;). Pipeline stages allows to parse log lines to extract more labels, &lt;a href=&#34;/docs/alloy/latest/reference/components/loki/loki.process/&#34;&gt;see associated documentation&lt;/a&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;loki-pipeline-stages&lt;/code&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;No&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
              &lt;td&gt;The pipeline stage configuration provided as a string &lt;a href=&#34;#pipeline-stages&#34;&gt;see pipeline stages&lt;/a&gt; and &lt;a href=&#34;/docs/alloy/latest/reference/components/loki/loki.process/&#34;&gt;associated documentation&lt;/a&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;loki-relabel-config&lt;/code&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;No&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
              &lt;td&gt;A &lt;a href=&#34;https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Prometheus relabeling configuration&lt;/a&gt; allowing you to rename labels &lt;a href=&#34;#relabeling&#34;&gt;see relabeling&lt;/a&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;loki-tenant-id&lt;/code&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;No&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
              &lt;td&gt;Set the tenant id (http header&lt;code&gt;X-Scope-OrgID&lt;/code&gt;) when sending logs to Loki. It can be overridden by a pipeline stage.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;loki-tls-ca-file&lt;/code&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;No&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
              &lt;td&gt;Set the path to a custom certificate authority.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;loki-tls-cert-file&lt;/code&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;No&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
              &lt;td&gt;Set the path to a client certificate file.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;loki-tls-key-file&lt;/code&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;No&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
              &lt;td&gt;Set the path to a client key.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;loki-tls-server-name&lt;/code&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;No&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
              &lt;td&gt;Name used to validate the server certificate.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;loki-tls-insecure-skip-verify&lt;/code&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;No&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;&lt;code&gt;false&lt;/code&gt;*&lt;/td&gt;
              &lt;td&gt;Allow to skip tls verification.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;loki-proxy-url&lt;/code&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;No&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
              &lt;td&gt;Proxy URL use to connect to Loki.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;no-file&lt;/code&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;No&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;&lt;code&gt;false&lt;/code&gt;*&lt;/td&gt;
              &lt;td&gt;Default is &amp;ldquo;false&amp;rdquo; and log files are created.  Set to &amp;ldquo;true&amp;rdquo; to tell driver not to ever create log files on disk. However, this means you won&amp;rsquo;t be able to use &lt;code&gt;docker logs&lt;/code&gt; on the container anymore. Use this setting if you don&amp;rsquo;t need to use &lt;code&gt;docker logs&lt;/code&gt; or run with limited disk space.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;keep-file&lt;/code&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;No&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;&lt;code&gt;false&lt;/code&gt;*&lt;/td&gt;
              &lt;td&gt;Default is &amp;ldquo;false&amp;rdquo; and log files are removed once a container is stopped. Set to &amp;ldquo;true&amp;rdquo; to tell driver to keep json log files once a container is stopped.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;max-size&lt;/code&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;No&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;-1&lt;/td&gt;
              &lt;td&gt;The maximum size of the log before it is rolled. A positive integer plus a modifier representing the unit of measure (k, m, or g). Defaults to -1 (unlimited). This is used by json-log required to keep the &lt;code&gt;docker log&lt;/code&gt; command working.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;max-file&lt;/code&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;No&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;1&lt;/td&gt;
              &lt;td&gt;The maximum number of log files that can be present. If rolling the logs creates excess files, the oldest file is removed. Only effective when max-size is also set. A positive integer. Defaults to 1.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;labels&lt;/code&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;No&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
              &lt;td&gt;Comma-separated list of keys of labels, which should be included in message, if these labels are specified for container.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;env&lt;/code&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;No&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
              &lt;td&gt;Comma-separated list of keys of environment variables to be included in message if they specified for a container.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;env-regex&lt;/code&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;No&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;&lt;/td&gt;
              &lt;td&gt;A regular expression to match logging-related environment variables. Used for advanced log label options. If there is collision between the label and env keys, the value of the env takes precedence. Both options add additional fields to the labels of a logging message.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;note&#34;&gt;*note:&lt;/h3&gt;
&lt;p&gt;Boolean values in the configuration file only accept the following string type:&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Value&lt;/th&gt;
              &lt;th style=&#34;text-align: center&#34;&gt;Accepted Values&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;true&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;&lt;code&gt;&amp;quot;1&amp;quot;, &amp;quot;t&amp;quot;, &amp;quot;T&amp;quot;, &amp;quot;true&amp;quot;, &amp;quot;TRUE&amp;quot;, &amp;quot;True&amp;quot;&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;false&lt;/td&gt;
              &lt;td style=&#34;text-align: center&#34;&gt;&lt;code&gt;&amp;quot;0&amp;quot;, &amp;quot;f&amp;quot;, &amp;quot;F&amp;quot;, &amp;quot;false&amp;quot;, &amp;quot;FALSE&amp;quot;, &amp;quot;False&amp;quot;&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h2 id=&#34;troubleshooting&#34;&gt;Troubleshooting&lt;/h2&gt;
&lt;p&gt;Plugin logs can be found as docker daemon log. To enable debug mode refer to the
&lt;a href=&#34;https://docs.docker.com/config/daemon/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Docker daemon documentation&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The standard output (&lt;code&gt;stdout&lt;/code&gt;) of a plugin is redirected to Docker logs. Such
entries are prefixed with &lt;code&gt;plugin=&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;To find out the plugin ID of the Loki logging driver, use &lt;code&gt;docker plugin ls&lt;/code&gt; and
look for the &lt;code&gt;loki&lt;/code&gt; entry.&lt;/p&gt;
&lt;p&gt;Depending on your system, location of Docker daemon logging may vary. Refer to
&lt;a href=&#34;https://docs.docker.com/config/daemon/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Docker documentation for Docker daemon&lt;/a&gt;
log location for your specific platform.&lt;/p&gt;
]]></content><description>&lt;h1 id="docker-driver-client-configuration">Docker driver client configuration&lt;/h1>
&lt;p>The Docker daemon on each machine has a default logging driver and
each container will use the default driver unless configured otherwise.&lt;/p></description></item></channel></rss>