Run cAdvisor when using Docker Compose
- One minute read - 117 wordscAdvisor
has long been a favorite monitoring tool of mine. I’m using Docker Compose for local testing and have begun including a cAdvisor
in my docker-compose.yaml
files.
cadvisor:
restart: always
image: google/cadvisor:${CADVISOR_VERSION}
container_name: cadvisor
# command:
# - --prometheus_endpoint="/metrics" # Default
volumes:
- "/:/rootfs:ro"
- "/var/run:/var/run:rw"
- "/sys:/sys:ro"
- "/var/snap/docker/current:/var/lib/docker:ro" #- "/var/lib/docker/:/var/lib/docker:ro"
expose:
- "8080"
ports:
- 8080:8080
I’d not realized until recently, that cAdvisor
also surfaces a Prometheus metrics endpoint and so, if you do follow this path and you’re also using Prometheus, don’t forget to add cAdvisor
to your Prometheus targets.
The primary advantage to this is being able to monitor services (containers) in the aggregate:
As well as for specific services (containers):
That’s all!