Sign inSign up

zachbg/docker-log

By zachbg

•Updated 6 months ago

Collect logs from all containers and forward to stdout, files, or Loki

Image
1

1.5K

zachbg/docker-log repository overview

⁠Docker Log Collector

Lightweight container log aggregator. Collects logs from all running containers and forwards them to stdout, files, or Loki.

⁠Why?

Docker logs are scattered across containers. This image collects them all into one stream, making it easy to pipe into any log system or just watch everything in one place.

⁠Quick Start

services:
  docker-log:
    image: zachbg/docker-log:latest
    restart: unless-stopped
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
    environment:
      LOG_FORMAT: json

⁠Environment Variables

VariableDefaultDescription
LOG_DRIVERstdoutOutput driver: stdout, file, loki, both
LOG_FORMATjsonFormat: json or text
LOKI_URLLoki push URL (e.g., http://loki:3100)
LOKI_LABELSjob=dockerExtra Loki labels
FILE_PATH/logsPath for file driver output
INCLUDE_LABELSOnly watch containers with these labels (comma-separated)
EXCLUDE_CONTAINERSSkip these container names (comma-separated)
SINCE5mHow far back to start collecting
FOLLOWtrueFollow logs in real-time

⁠Examples

⁠Forward to Loki
services:
  docker-log:
    image: zachbg/docker-log:latest
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
    environment:
      LOG_DRIVER: loki
      LOKI_URL: http://loki:3100
      LOKI_LABELS: "job=docker,env=prod"
⁠Save to files
services:
  docker-log:
    image: zachbg/docker-log:latest
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ./logs:/logs
    environment:
      LOG_DRIVER: file
      LOG_FORMAT: text
⁠Watch specific containers only
services:
  docker-log:
    image: zachbg/docker-log:latest
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
    environment:
      INCLUDE_LABELS: "app=web,logging=enabled"
      EXCLUDE_CONTAINERS: "docker-log,monitoring"

Tag summary

Content type

Image

Digest

sha256:dee970895…

Size

16.7 MB

Last updated

6 months ago

docker pull zachbg/docker-log