Shipping Docker container logs to Loki

Teams running Docker containers on infrastructure they control need a clear collection method, sensible labels and a support position they can defend. This page compares Grafana Alloy with the Loki Docker logging driver and sets out how to configure each.

On this page

Shipping Docker container logs to Loki: which method to pick and why

If your containers run on hosts you operate and their logs need to land in self-hosted Loki and Grafana, you have two supported routes. Grafana Alloy is Grafana's supported log shipper for Loki, and the Loki Docker logging driver is a supported client with a lower support commitment. Alloy runs as a separate agent that reads container logs from the Docker runtime, attaches labels and forwards them to Loki. The Docker driver works differently: you tell the Docker daemon to send each container's stdout and stderr straight to Loki, so no agent process sits between the container and the push.

The practical question is which of these your team can own over the life of the platform. Alloy gives you a single pipeline you can extend with relabeling, filtering, rate limiting and the same configuration you use for host logs, syslog and Kubernetes. The Docker driver is simpler to start with, but it is maintained in the Loki project and listed among third-party clients, so it does not carry the support commitment that Alloy does. Confirm the current support terms with Grafana before you standardize on it. The driver also reads Docker's logging configuration, so changes to it apply per container or per daemon and need to be tracked like any other host setting.

The driver does not run on Windows. If any hosts in scope are Windows container hosts, plan for Alloy there or for another collection path, and confirm the platform matrix in the Loki Docker driver documentation before you commit. Whichever method you choose, decide the label set before rollout, because it determines how streams are indexed and how teams filter in Grafana. For the driver's setup and options, read the Loki Docker driver documentation before changing any daemon configuration.

What you need before shipping Docker logs to Loki

Shipping container logs to Loki depends on four things lining up: a Loki endpoint the Docker hosts can reach, Docker access on each host, tenant identifiers if multi-tenancy is on, and an authenticating proxy in front of Loki. Check each one before choosing a collection method, because the answers decide which configuration you write.

A reachable self-hosted Loki

Confirm that every Docker host can open a network path to the Loki push endpoint, and that the deployment mode you run (monolithic, simple scalable or microservices) is the one you intend to keep. Simple scalable mode is being deprecated and removed with Loki 4.0, so a new container log pipeline should not be built against it without a migration plan. Confirm the write path is sized for your container count and log volume, since every host adds a continuous stream of push traffic.

Loki deployment modes

Docker Engine and host access

The method you choose sets the access you need. The Docker logging driver is configured in the daemon or per container, so it requires changes on each host and a Docker Engine restart after plugin installation. An Alloy agent that reads container logs needs access to the Docker socket or log files on the host, which is a privileged permission you should review with your security team. Record the Docker Engine version and the host operating system for every host class you will cover.

Tenant IDs when auth is enabled

If auth_enabled is true on your Loki cluster, every write must carry an X-Scope-OrgID header that names the tenant. Agree the tenant mapping before you deploy: one tenant per environment, per team or per customer. Alloy sets this value through its client configuration, while the Docker driver must be given the tenant through its own options. A missing or mismatched tenant value causes rejected writes, so test one host end to end before rolling out the rest.

Loki multi-tenancy docs

An authenticating reverse proxy

Loki has no built-in authentication layer, so the documentation requires an authenticating reverse proxy in front of it, such as nginx, HAProxy, OAuth2 Proxy or Pomerium. Decide which credential the hosts will present, how it is stored on each host, and how it is rotated. Confirm the proxy passes the push path and the tenant header through unchanged, because a proxy that strips headers will break multi-tenant writes in ways that look like authentication failures.

Loki authentication docs

Current Docker and Alloy versions

Confirm the Docker Engine, Docker logging driver plugin and Grafana Alloy versions you plan to run against the current documentation rather than relying on this page, because option names, plugin installation steps and supported platforms change between releases. Check the Loki release you run as well, since the latest tagged release is the reference for client compatibility. Pin the versions you test so that a host update does not change log shipping behavior silently.

Platform limits to plan for

Confirm which hosts run Windows before you commit to the Docker driver, because the driver does not run on Windows and those hosts will need a different collection path. Also confirm that the Docker driver sits among third-party clients rather than Alloy in terms of support commitment, so your operations team knows where vendor support applies. Write down which host classes will use which method before you start the rollout.

Alloy or the Docker logging driver: how to decide

Grafana Alloy is Grafana's supported log shipper for Loki, so it is the option that Grafana Labs names as the default path for new collection work. The Loki Docker driver is maintained within the Loki project, but the Loki documentation lists it among third-party clients, which means it does not carry the same support commitment as Alloy. Neither choice removes the need for your own operating procedures, but the support position changes who you call when a log pipeline breaks and what you can reasonably expect from a vendor response.

  • Alloy: Grafana Labs supports it as the shipper for Loki, and it also covers other sources such as journald, Kubernetes and syslog, so one agent standard can serve several teams.
  • Docker driver: Maintained in the Loki project and documented, but listed among third-party clients without the Alloy support commitment.
  • Contract check: If your support contract with Grafana Labs or a partner covers only Alloy, a driver-based design may fall outside what you can escalate.
  • Operating model: Teams that already run a single agent standard may prefer one shipper for all hosts instead of a second path for containers.
  • Confirm: Ask your vendor or partner in writing which collection methods are covered under your agreement.

Before choosing, check the decision against your support contract and operating model, not just the technical fit.

Configuring container log shipping to Loki step by step

This sequence takes container logs from a Docker host into self-hosted Loki with the chosen client, labels each stream by container, image and compose project, and proves the result in Grafana before the setup goes into regular use.

  1. Confirm the Loki endpoint and tenant

    Before touching any host, record the Loki push URL that the client will use, whether the cluster runs with authentication enabled, and which tenant ID the container logs should be written under. If authentication is enabled, every request must carry the X-Scope-OrgID header, so the client configuration needs that value. Confirm with the team that operates Loki that the endpoint is reachable from the Docker hosts through the authenticating reverse proxy, since Loki has no built-in authentication layer. Done means a test request from a Docker host to the push endpoint succeeds with the expected tenant ID.

  2. Choose the client and install it

    Decide between Grafana Alloy, which reads container logs through the Docker socket and is the supported log shipper for Loki, and the Loki Docker logging driver, which ships logs from the container runtime itself and sits among third-party clients with a lower support commitment. Record the choice and the reason, including whether any host runs Windows, because the Docker logging driver does not run there. Install the selected component on one non-production host first. Done means the client process or plugin starts without errors and reports a healthy state on that host.

  3. Define which containers and streams are collected

    Write the collection rules so that only the intended containers are read. With Alloy, this means selecting containers by name, label or compose project in the Docker discovery configuration. With the logging driver, the selection is made per container with the log-driver and log-opt settings in the run command or compose file, so each service must be changed individually. Exclude noisy or sensitive containers deliberately rather than by accident. Done means a list of target containers matches the discovery output on the test host.

  4. Set labels for container name, image and compose project

    Attach a small, fixed set of labels such as container name, image name and compose project to each stream. Keep label values bounded: container IDs, random hostnames and per-request values belong in structured metadata or are dropped, because each unique label combination creates a separate stream. Write the label names into the configuration exactly as they will be queried, for example the same spelling in every service. Done means a sample stream in the client debug output shows only the agreed labels and no unbounded values.

  5. Send a test container log

    Start a small, disposable container that writes a unique, recognizable string, such as a timestamped marker line, to standard output at a known moment. Keep the container name and image specific to the test so the stream can be identified without ambiguity. Use the test to confirm that the client reads the container output and forwards it without dropping the line. Done means the client logs show the line was accepted by Loki and returned no push errors.

  6. Confirm the test line in Grafana with the expected labels

    In Grafana, open Explore with the Loki data source for the tenant and run a LogQL stream selector that matches the test container's name or image label. The query should return the unique marker line and only the labels defined in the earlier step. If nothing appears, check the tenant header, the endpoint and the label selector before changing the collection rules. Done means the selector returns the marker line from the correct stream, and the label set shown in Grafana matches the configuration.

  7. Roll out to production hosts and record the setup

    Apply the same configuration to the remaining Docker hosts, then repeat the marker test on at least one container per host to confirm each host writes under the intended tenant and labels. Record the client version, configuration files, label list and the verification query in the operations runbook so that upgrades and audits can repeat the checks. Done means each production host returns its marker line through the agreed LogQL query and the runbook lists the verified configuration.

Setting labels per container without creating too many streams

Each unique combination of labels is a separate stream in Loki, so the labels you attach to container logs decide how many streams your cluster holds and how fast queries run. Loki indexes only labels, not the log text, so a container's stream is defined by its label set: for example, a container name, a compose_service or application name, a host, and an environment. Every distinct value combination creates a new stream, and each stream carries its own index entries and chunk storage. Before you configure the Docker logging driver or Alloy, write down the label set you intend to use and confirm which keys are stable across redeploys.

Values that change with every container start, such as container IDs, random Compose suffixes, or per-request identifiers, are high-cardinality and should not become labels. A container ID changes each time a container is recreated, so labelling with it quietly multiplies streams and leaves short-lived streams behind. Keep the label set small and stable: service or application name, environment, and host are usually enough to find logs, and the rest of the metadata can stay in the log line or in structured metadata. The Docker logging driver lets you pass labels and extra attributes per container, so review those options in your Compose files and run a test deployment to see which keys end up as stream labels. Confirm the exact behavior of your Loki version with the driver documentation before you roll it out. Label choice drives both query speed and storage cost, because queries select streams by label before scanning content. For the decisions behind label sizing and how to handle high-cardinality data, see the Loki labels and cardinality group guidance in this series.

Mapping Docker metadata to Loki labels and fields

This table compares each Docker attribute a container log carries with where it should land in Loki: as a stream label, as structured metadata or left out. Read it as a starting point for label design, then confirm the attribute names your chosen client version produces before you write the pipeline. The main takeaway is that container name and compose service are usually useful labels, while stream and container ID need more care.

Docker attributeSuggested placement in LokiWhyConfirm before use
Container nameLabelBounded per host and useful for finding a service's logs, but it changes when containers are recreated.Name format from your client and whether recreated containers reuse names
Compose serviceLabelStable across container restarts and replicas, so it keeps stream counts low for typical Compose projects.Whether your client exposes the Compose service label by default
Image nameLabel or structured metadataHelpful for filtering by release, but tags change often and can multiply streams during rollouts.Whether to store the image tag or only the repository name
HostLabelSeparates logs from several Docker hosts in one Loki tenant, and the set of hosts is usually small.Whether the host value comes from the agent or from your Alloy configuration
Stream (stdout or stderr)Label or structured metadataOnly two values, so it is safe as a label, but many teams keep it as metadata to reduce label sets.Attribute name used by your client version and how it appears in queries
Container IDStructured metadata or omitUnique per container and changes on every restart, so as a label it creates a new stream each time.Whether the attribute is exposed at all in your client version
Log message fieldsStructured metadata or left in the lineFree-form values such as request IDs or user IDs create unbounded cardinality if promoted to labels.Whether your application logs JSON and how you parse it in the pipeline

Securing container log access and transport

Container logs often contain tokens, connection strings and personal data, and Loki itself does not authenticate anyone. The controls below sit around Loki and the Docker hosts, so access, tenant separation and transport need to be designed together before the first container ships a line.

Put an authenticating proxy in front of Loki

Loki has no built-in authentication layer. Its documentation expects you to run an authenticating reverse proxy such as nginx, HAProxy, OAuth2 Proxy or Pomerium in front of it, so every push and query is checked before it reaches Loki. Confirm which identity the proxy enforces for writers (the Alloy or driver credential) and for readers (people in Grafana), and keep those two paths separate. A shared password on the push endpoint is the most common gap we see in reviews.

Loki authentication docs

Separate tenants with X-Scope-OrgID

When auth_enabled is true, Loki treats every request as belonging to a tenant identified by the X-Scope-OrgID header. The proxy should set or validate this header from the authenticated identity, so a client cannot choose another team's tenant by editing its own configuration. Decide whether each Docker host writes to one tenant or whether per-application tenants are worth the added limits and query handling.

Loki multi-tenancy docs

Protect the Docker daemon and socket

Any process that can reach the Docker socket can read container metadata and, with enough privilege, the logs of every container on the host. Keep /var/run/docker.sock restricted to the root group, avoid mounting it into the logging agent container, and if you expose the daemon over TCP, require TLS client certificates. Review the daemon.json file, which holds the logging driver and its options, under the same change control as the rest of the host.

Encrypt traffic between hosts and Loki

Log lines and the labels attached to them travel from each Docker host to the proxy and then to Loki. Terminate TLS at the proxy with certificates from your own CA, and make the Docker driver or Alloy verify the server certificate rather than skipping verification. Confirm that the internal path from the proxy to Loki is also encrypted if it crosses a network segment you do not fully control.

Limit who can read container logs

Logs from an application frequently include request bodies, stack traces and secrets printed by mistake. Grant read access by tenant and, where your Grafana setup allows it, by stream labels, and review who holds the Explore role. Because the open-source Loki build does not provide label-based access control, confirm with your team whether that requirement is met by tenant separation alone or needs a different access design.

Redact before logs leave the host

Removing sensitive values at the source is more reliable than trying to scrub them later in Loki. Use Alloy's processing stages or the application's own logging configuration to mask tokens, card numbers and personal identifiers before the line is sent, and keep the redaction rules in version control. Test them with real-looking but fake secrets, and treat logs already stored in Loki as sensitive until retention removes them.

Why container logs go missing or land under the wrong labels

This table pairs each common failure when shipping Docker container logs to Loki with its likely cause and a general fix. Read it when logs are absent, rejected or carry unexpected labels, and check the cause column against your own setup before changing anything.

SymptomLikely causeGeneral fix
No logs for an existing containerThe logging driver was changed after the container was created, so the running container still uses its original driverRecreate the container so it starts with the new logging driver, then confirm new log lines arrive in Loki
Requests rejected with an authorization or tenant errorLoki runs with auth_enabled set to true but the client sends no X-Scope-OrgID header, or the header value names a tenant the proxy does not allowSet the tenant header in the client configuration, and confirm the reverse proxy in front of Loki passes the header through and checks the caller's access
Streams rejected for too many label combinationsA label carries a value that changes on every event, such as a container ID, request ID or timestamp, so each value creates a new streamKeep labels to stable values such as container name, image and host, and move per-event detail into the log line or structured metadata
Alloy reports no containers or permission errorsAlloy cannot reach the Docker socket, usually because the container or service account is not allowed to mount or read itGrant read access to the Docker socket through the deployment settings, then check the Alloy logs for discovery errors
Container logs missing on a Windows hostThe Loki Docker logging driver does not run on WindowsUse Grafana Alloy on the Windows host to collect container output, and confirm the approach with your Windows container setup before rollout
Labels look wrong or are missing on some streamsLabel mapping was set once for one container type and does not match the labels other containers produceDefine the label set per container in one configuration, and check a sample query in Grafana to confirm each stream carries the expected labels
Logs arrive but the Docker driver stops shipping after a host restart or driver errorThe driver is third-party-style support with a lower support commitment than Alloy, so troubleshooting relies more on your own teamConfirm how your team will support the driver before choosing it, or move the collection path to Alloy

How container logs flow from Docker to Loki

Container logs start as the stdout and stderr streams that each container writes. Docker captures those streams and hands them to a log driver, and that handoff is where your choice of client matters. With the Docker logging driver, Docker sends each line straight to Loki over HTTP. With Grafana Alloy, Docker's default json-file logs are read from the host, parsed, labeled and then pushed to Loki. Either way, the client is the only component that touches the container runtime, so it determines which container metadata you can turn into labels and how much processing happens before a line leaves the host.

Once a client pushes a batch, Loki's write path receives it, groups lines into streams by their label set and writes compressed chunks plus index data to object storage. Loki does not keep the logs on the node that produced them, so the object store and the compactor, which applies retention, become the durable layer you must size and back up. Queries then run in the other direction: Grafana sends LogQL to Loki's read path, which uses the index to find the relevant chunks in object storage and returns matching lines. Confirm in your own environment which Loki deployment mode and object store you run, because the write and read components you scale depend on them. Ask your vendor or the Loki deployment modes documentation to map these components onto your topology before you pick a client.

Container log flow from Docker hosts to Grafana

The flow starts with containers writing stdout and stderr to the Docker engine, which hands the logs to either Grafana Alloy reading the Docker log source or the Loki Docker logging driver pushing directly. Both paths cross the trust boundary into the Loki network, where a reverse proxy that performs authentication sits in front of Loki. Loki writes compressed chunks and its index to object storage, and Grafana queries Loki through the proxy. Check that the proxy enforces identity on every write and read, and that the X-Scope-OrgID tenant header is set consistently on both paths.

Container logs reach Loki through Alloy or the Docker driver, then through an authenticating proxy.

Questions teams ask before shipping Docker logs to Loki

Is the Loki Docker driver a good long-term choice for container logs?

It can work, but it carries a weaker support position than Grafana Alloy, so plan for that before you standardize on it. The Loki Docker driver reads container logs and ships them to Loki, and it is maintained within the Loki project. It is listed among third-party clients, however, and does not carry the support commitment that Grafana Alloy has. Grafana's supported log shipper for Loki is Alloy, and Promtail reached end of life on March 2, 2026. Ask your Grafana Labs contact or your support provider what support covers the driver, and check its release notes against your Docker Engine version before committing. If your estate is mostly Linux hosts, a single Alloy deployment often gives you one supported path for host, container and Kubernetes logs.

What actually drives the effort of shipping Docker logs to Loki?

The main drivers are the number of hosts, the number of containers per host, your label design, and the authentication and proxy work in front of Loki. Each host needs a configured collector or driver, and each container's labels need to follow a standard so that queries stay fast and costs stay predictable. Label design is often the largest effort, because labels such as container ID or a free-text service name create many streams. Loki has no built-in authentication layer, so an authenticating reverse proxy such as nginx, HAProxy, OAuth2 Proxy or Pomerium must sit in front of it, and every shipper must send the tenant header through that proxy. Tenant separation and retention rules add more configuration on top of these.

Can our own team set this up using the Loki documentation alone?

A capable platform team can usually do it from the documentation, provided it has time to test and someone owns the label standard. The official send-data guidance covers the Docker driver and Alloy, and the Loki authentication and multi-tenancy pages explain the proxy and the X-Scope-OrgID header. What the documentation does not decide for you is how your containers should be labeled, which hosts should be covered first, how long logs are kept, and who can read which tenant. Those choices are where most rework happens. Test with a few hosts, agree the label set in writing, and then roll out. If your team lacks a Loki owner or a reverse proxy pattern already in use, that gap is worth naming early.

How long does a Docker-to-Loki rollout take?

Duration depends on scope, and no fixed figure applies to every estate. A pilot on a handful of hosts is short when Loki, the proxy and dashboards already exist. Work grows with the number of hosts, the number of distinct container workloads, how many teams need access, and whether authentication and retention still have to be built. Ask any provider for a timeline tied to a written scope that lists hosts, label standard, proxy design, retention and the Grafana access model. A fixed-scope agreement makes those assumptions visible before work starts.

What must our team provide before the work starts?

You need to provide working Loki access, host access for the containers being collected, and a label standard that someone with authority has approved. Loki access means a running cluster or a agreed deployment target, the object storage it writes to, and the reverse proxy that enforces authentication. Host access means administrative rights or a change path for the Docker daemon configuration on each host, and a maintenance window to restart it where needed. The label standard should name the labels each container must carry, the labels that must never be used, and the tenant each workload belongs to. Confirm these items in the scope document so that delays do not come from missing access.

Can Windows hosts be covered by the same method?

No. The Docker logging driver does not run on Windows, so Windows hosts need a different collection method. Grafana Alloy includes a windowsevent source for Windows Event Log channels, which is the route to use for Windows event data. Container logs from Windows container hosts should be confirmed separately with the Alloy documentation and tested in your environment before you promise coverage. Plan Windows as its own workstream with its own label standard, so that Linux container labels do not get reused for Windows sources without review.

Does shipping container logs to Loki affect what we must retain and protect?

Yes. Retention in Loki is disabled by default, so logs are kept until you enable it, which makes container logs a retention and access decision from day one. Retention is applied by the compactor and can be set globally, per tenant or per stream selector, with each stream rule at least 24 hours. Container logs often contain personal data, tokens or internal hostnames, so decide what is redacted before shipping and who may query each tenant. Enable retention in the first configuration, and confirm with your compliance team which retention periods apply to each log source.

How DeployOpen scopes and delivers Docker log shipping for Loki

DeployOpen plans Docker container log shipping to Loki as a fixed-scope piece of work inside your own infrastructure. We agree in writing which hosts, container runtimes, labels and Grafana access are covered before any configuration changes are made.

How we scope

  • Inventory the Docker hosts, container runtimes and Linux or Windows nodes that need log collection
  • Decide with you whether Grafana Alloy, the Loki Docker driver or both will ship logs for each host
  • Agree the label set per container, such as service, environment and team, before any stream is created
  • Record the Loki tenant, retention expectations and Grafana access model in the written scope

How we build

  • Configure the chosen collector on a non-production host first and confirm labels appear as planned in Grafana
  • Apply container-to-label mappings and drop rules so noisy containers do not create unplanned streams
  • Test log loss during container restarts, host reboots and collector restarts before rollout
  • Roll the configuration out host by host, with a rollback path for each host group

How we hand over

  • Deliver the collector configuration files, label reference and host inventory as versioned artifacts
  • Document how to add a new container, host or label and which changes require review
  • Provide a verification checklist your team can rerun after a Docker or collector upgrade
  • Walk your operators through dashboards and LogQL queries used to confirm each container's logs

How we support

  • Ongoing support, upgrades and continuous testing are available as a retainer after handover
  • Retainers can cover collector version updates and checks when Docker or Loki releases change behavior
  • Ask any support provider to confirm response scope, change control and who owns the configuration after handover
  • Confirm in the quote whether support covers Loki itself as well as the container log pipeline

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.