Skip to content
🎉 Launch sale:50% off everything over $22 — automatically applied at checkout· ends Aug 2Shop the sale →
DevOps AI ToolKit
Newsletter

Loki + Promtail Docker Compose Example

Grafana Loki with Promtail shipping container logs.

The compose.yaml

name: logging
services:
  loki:
    image: grafana/loki:3.3.2
    command: -config.file=/etc/loki/local-config.yaml
    restart: unless-stopped
    ports:
      - 127.0.0.1:3100:3100
    volumes:
      - loki_data:/loki
    logging:
      driver: json-file
      options:
        max-size: 10m
        max-file: '3'
  promtail:
    image: grafana/promtail:3.3.2
    command: -config.file=/etc/promtail/config.yml
    restart: unless-stopped
    volumes:
      - /var/log:/var/log:ro
      - ./promtail-config.yml:/etc/promtail/config.yml:ro
    depends_on:
      - loki
    logging:
      driver: json-file
      options:
        max-size: 10m
        max-file: '3'
volumes:
  loki_data: {}

Start it up

# Validate the configuration (does not start anything):
docker compose -f compose.yaml config

# Pull images and start in the background:
docker compose -f compose.yaml pull
docker compose -f compose.yaml up -d

# Check status and follow logs:
docker compose -f compose.yaml ps
docker compose -f compose.yaml logs -f

# Stop and remove (named volumes are kept):
docker compose -f compose.yaml down

Services

  • lokigrafana/loki:3.3.2
  • promtailgrafana/promtail:3.3.2

Security notes

  • warning
    No healthcheck
    Add a `healthcheck:` that probes a readiness endpoint or a CLI check for the service.
  • warning
    No healthcheck
    Add a `healthcheck:` that probes a readiness endpoint or a CLI check for the service.
  • warning
    Stateful service without a named volume
    Mount a named volume at the data path (e.g. `pgdata:/var/lib/postgresql/data`) and declare it under top-level `volumes:`.
  • warning
    No memory limit
    Set a memory limit sized to the workload (e.g. `mem_limit: 512m`).
  • warning
    No memory limit
    Set a memory limit sized to the workload (e.g. `mem_limit: 512m`).
  • warning
    Source-code bind mount (development pattern)
    Bake code into the image; keep bind mounts in a separate `compose.override.yml` used only for local development.

Open the template in the generator to apply one-click hardening.

FAQ

How do I run this Loki + Promtail Docker Compose file?

Save it as compose.yaml, then run `docker compose up -d`. Validate first with `docker compose config` and follow logs with `docker compose logs -f`.

Do I need a version field in the Loki + Promtail Compose file?

No — modern Docker Compose does not require a top-level version field, and this example does not include one.

How do I customize this Loki + Promtail template?

Open it in the free Docker Compose Generator to change images, ports, volumes, networks, environment variables, and health checks visually, then download your compose.yaml.

Independent educational example. "Docker" is a trademark of Docker, Inc. Review and adapt before using in production.