NVIDIA GPU metrics exporter for Prometheus.
Educational example only. Review every volume path, port, and credential before you run this. Do not copy production secrets into your wiki or git repo.
_shared/.env for non-secrets, _shared/.secret for credentialsmkdir -p /path/to/docker/stacks/dcgm-exporter
cd /path/to/docker/stacks/dcgm-exporter
# paste compose.yaml below, then:
docker compose pull
docker compose up -d
---
services:
dcgm-exporter:
image: nvcr.io/nvidia/k8s/dcgm-exporter:2.0.13-2.1.2-ubuntu18.04
container_name: dcgm-exporter
env_file:
- /path/to/docker/stacks/_shared/.env
- /path/to/docker/stacks/_shared/.secret
logging:
driver: json-file
options:
max-file: ${DOCKERLOGGING_MAXFILE:-10} # Max number of log files
max-size: ${DOCKERLOGGING_MAXSIZE:-200k} # Max file size
# Use the NVIDIA runtime
runtime: nvidia
# Expose the metrics port on the host
ports:
- "9400:9400"
# Provide access to all GPUs
deploy:
resources:
reservations:
devices:
- capabilities: ["gpu"]
# Optional: mount the procfs for additional system metrics
volumes:
- /proc:/host/proc:ro
# Optional: use the host network namespace
# network_mode: host
restart: unless-stopped
_shared/.secret.