HUB
Sign inSign up
docker_exporter logo

rcooler/docker_exporter

By rcooler

•Updated 7 months ago

Lightweight Docker Compose project and container metrics for Prometheus and Home Assistant.

Image
1

2.8K

rcooler/docker_exporter repository overview

This project evolved into rcooler/ugos-bridge⁠ (UgosBridge), a metrics bridge for UGREEN NAS hosts and Docker Compose stacks that adds host, storage, network, GPU, VM and hardware health telemetry to the Docker metrics. New installations should use rcooler/ugos-bridge. Its configuration variables and metric names differ from this image, so treat it as a new installation.

The guide below describes the last docker_exporter image, 1.0.0.

⁠Quick overview

docker_exporter is a lightweight Docker metrics exporter for Docker Compose style projects. It collects a small set of project and container metrics from the Docker Engine API and exposes them to Prometheus and, optionally, to Home Assistant through MQTT Discovery, without the overhead of cadvisor.

  • Per-container and per-project CPU usage percent and memory usage bytes.
  • Total and running containers per project.
  • Prometheus metrics endpoint, MQTT JSON state publishing, Home Assistant MQTT discovery.
  • Source and documentation: GitHub⁠

⁠Changelog⁠

⁠1.0.0 - 2026-04-21
  • First published image.

Full history: commits on GitHub⁠. Development continues in UgosBridge: changelog⁠.

⁠Installation

⁠Docker run
docker run -d \
  --name docker-exporter \
  -p 9877:9877 \
  -v /var/run/docker.sock:/var/run/docker.sock:ro \
  rcooler/docker_exporter:latest
⁠Docker Compose
services:
  docker-exporter:
    image: rcooler/docker_exporter:latest
    restart: unless-stopped
    ports:
      - "9877:9877"
    environment:
      DOCKER_HOST: "unix:///var/run/docker.sock"
      DOCKER_EXPORTER_MQTT_ENABLED: "true"
      DOCKER_EXPORTER_MQTT_BROKER: "tcp://host.docker.internal:1883"
      DOCKER_EXPORTER_MQTT_USER: "ha"
      DOCKER_EXPORTER_MQTT_PASS: "change_me"
      DOCKER_EXPORTER_MQTT_CLIENT_ID: "docker_exporter"
      DOCKER_EXPORTER_MQTT_TOPIC_PREFIX: "docker_exporter"
      DOCKER_EXPORTER_MQTT_DISCOVERY_PREFIX: "homeassistant"
      DOCKER_EXPORTER_MQTT_INTERVAL: "60"
      DOCKER_EXPORTER_MQTT_RETAIN: "true"
      DOCKER_EXPORTER_MQTT_EXPIRE_AFTER: "360"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro

Full example file: docker-compose.example.yml⁠

DOCKER_EXPORTER_MQTT_INTERVAL and DOCKER_EXPORTER_MQTT_EXPIRE_AFTER accept either plain seconds like 60 and 360, or Go duration strings like 60s and 6m. Leave the MQTT variables out to run with Prometheus only.

⁠Prometheus scrape job
  - job_name: 'docker-exporter'
    static_configs:
      - targets: ['docker-exporter:9877']
⁠Metrics
  • docker_exporter_container_cpu_usage_percent, docker_exporter_container_memory_usage_bytes, docker_exporter_container_memory_limit_bytes
  • docker_exporter_container_running, docker_exporter_container_stats_collected, docker_exporter_container_stats_errors
  • docker_exporter_project_cpu_usage_percent, docker_exporter_project_memory_usage_bytes
  • docker_exporter_project_total_containers, docker_exporter_project_running_containers
  • docker_exporter_up, docker_exporter_last_collection_timestamp_seconds
⁠Main environment variables
VariablePurpose
LISTEN_ADDRESSHTTP listen address. (default: :9877)
METRICS_PATHPath that serves the metrics. (default: /metrics)
SCRAPE_INTERVALDelay between collection cycles. (default: 15s)
DOCKER_HOSTDocker Engine API endpoint. (default: unix:///var/run/docker.sock)
DOCKER_TIMEOUTTimeout for Docker API requests. (default: 5s)
DOCKER_PROJECT_LABELLabel that names the project. (default: com.docker.compose.project)
STANDALONE_PROJECT_NAMEProject name for containers without that label. (default: standalone)
CONTAINER_CONCURRENCYNumber of containers queried in parallel. (default: 4)

⁠PS

  • Projects are detected from the label com.docker.compose.project. Containers without that label are grouped under standalone.
  • Supported Docker host schemes: unix://, tcp://, http://, https://. npipe:// is not implemented.
  • The Docker socket mount is enough for Linux deployments.

MIT licensed. Independent open-source project, not affiliated with, endorsed by, or sponsored by Docker, Prometheus, or Home Assistant. Product names are trademarks of their respective owners and are used only to describe compatibility and integration.

Tag summary

Content type

Image

Digest

sha256:3893d1d00…

Size

5.7 MB

Last updated

7 months ago

docker pull rcooler/docker_exporter