Cloud Native 5 min read

Monitoring Docker Containers with cAdvisor and Prometheus

This guide explains how to monitor Docker containers using the open‑source cAdvisor tool, integrate its metrics with Prometheus, and visualize the data in Grafana, providing step‑by‑step commands and configuration examples for a complete container‑monitoring solution.

DevOps Operations Practice
DevOps Operations Practice
DevOps Operations Practice
Monitoring Docker Containers with cAdvisor and Prometheus

Containers have become ubiquitous, and mastering their usage and monitoring is an essential skill for operations engineers.

Among open‑source container runtimes such as Docker, Containerd, Podman, and LXC, this article uses Docker as an example to demonstrate container monitoring with Prometheus.

01 cAdvisor Tool

cAdvisor is a Google‑open‑source visual tool for monitoring and displaying container runtime status. It runs directly on the host, collects information from all running containers, and provides a query interface and HTTP endpoint for systems like Prometheus.

Installation is straightforward via a container image:

$ docker pull google/cadvisor:latest

Run the container with the necessary volume mounts:

$ docker run \
  --volume=/:/rootfs:ro \
  --volume=/var/run:/var/run:rw \
  --volume=/sys:/sys:ro \
  --volume=/var/lib/docker/:/var/lib/docker:ro \
  --volume=/dev/disk/:/dev/disk:ro \
  --publish=8080:8080 \
  --detach=true \
  --name=cadvisor \
  --privileged=true \
  google/cadvisor:latest

The command mounts several directories (read‑only ro or read‑write rw ) so cAdvisor can collect data; --detach runs it as a daemon and --name assigns a container name. On RHEL, CentOS, Fedora, the --privileged=true flag may be required.

Verify the container is running:

$ docker ps | grep cadvisor
13eb99bc02ce   google/cadvisor:latest   "/usr/bin/cadvisor -…"   19 minutes ago   Up 19 minutes   0.0.0.0:8080->8080/tcp   cadvisor

Access the web UI at http://$ip:8080 to view cAdvisor’s dashboard.

Visiting http://$ip:8080/metrics shows the raw Prometheus‑compatible metrics.

02 Prometheus Integration

cAdvisor provides rich metrics and a web UI, but it only retains data for about two minutes and requires logging into each host individually in multi‑host environments.

Integrating with Prometheus solves these issues by scraping and storing the metrics. Because cAdvisor already exposes a Prometheus‑format endpoint, you only need to define a job in Prometheus:

- job_name: 'docker'
  static_configs:
    - targets:
      - '192.168.214.108:8080'
      labels:
        group: docker

After loading this configuration, Prometheus begins collecting the cAdvisor metrics, which can be queried from the Prometheus UI.

03 Grafana Visualization

Grafana offers many Docker‑related dashboards. To import one:

Select Create → Import in Grafana.

Enter the dashboard ID and click Load .

Choose the Prometheus data source you configured earlier and click Import .

Once imported, the new dashboard displays real‑time container metrics collected by Prometheus.

For further reading, see related articles on monitoring MySQL and Nginx with Prometheus.

Cloud NativedockerPrometheusGrafanaContainer MonitoringcAdvisor
DevOps Operations Practice
Written by

DevOps Operations Practice

We share professional insights on cloud-native, DevOps & operations, Kubernetes, observability & monitoring, and Linux systems.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.