Monitoring Containers with cAdvisor — Part 2 of My Previous Blog Series

 Raees Qazi | DevOps Engineer | Learner | Mentor | Creator | CEO-Briller Technologies

 Today I’m going to talk about cAdvisor, which continues from my previous blog: https://brillertechnologies.blogspot.com/2025/11/prometheus-and-grafana-projectpart-1-by.html

After running our application, the next important step is monitoring — and for that, we use cAdvisor, a monitoring tool created by Google.


What is cAdvisor?

cAdvisor stands for Container Advisor.
 Its job is to show the resource usage and performance statistics of your running containers — things like CPU, RAM, network, and filesystem usage.

cAdvisor reads data directly from Docker’s internal directory, which is located at:

/var/lib/docker

So it needs read access to this path.

Configuring cAdvisor in Docker Compose

Now let’s update our docker-compose.yml file to include cAdvisor.

Open the file:

vim docker-compose.yml

Networks Section

networks:
monitoring:
driver: bridge

Services Section

1. Node Todo App

services:
note-todo:
build:
context: ./node-todo-cicd
ports:
- "8000:8000"
container_name: note-todo
networks:
- monitoring

2. cAdvisor Service

cadvisor:
image: gcr.io/cadvisor/cadvisor:latest
container_name: cadvisor
ports:
- "8080:8080"
volumes:
- /:/rootfs:ro
- /var/run:/var/run:rw
- /sys:/sys:ro
- /var/lib/docker/:/var/lib/docker:ro
networks:
- monitoring
depends_on:
- redis

3. Redis Cache

redis:
image: redis:latest
container_name: redis
ports:
- "6379:6379"
networks:
- monitoring
All services run on the same network (monitoring).

Save and exit:

:wq

Start the Updated Setup

Shut down old containers:

docker compose down

Start containers with the new configuration:

docker compose up -d

Accessing cAdvisor

Since cAdvisor exposes port 8080, make sure this port is allowed in your EC2 Security Group.

Then open:

http://<your-ec2-ip>:8080

You should now see the cAdvisor dashboard.
 It will automatically collect and display the metrics for all running containers.

In this setup, we have 3 containers running:

  1. Node Todo App
  2. Redis
  3. cAdvisor

I hope you found this blog helpful.
 Please like, share, and follow for more DevOps content.

🌐 Online References

  • LinkedIn: https://www.linkedin.com/in/raees-yaqoob-qazi-ryqs/
  • Medium Blog: https://medium.com/@raeesyaqubqazi
  • Blogspot: https://brillertechnologies.blogspot.com/
  • Facebook Page: https://web.facebook.com/profile.php?id=61553548371216
  • YouTube Channel: https://www.youtube.com/@RaeesQ.
  • TikTok: https://www.tiktok.com/@mrryqs?_t=ZS-8y7t0fQfJKu&_r=1

 


Comments

Popular posts from this blog

📘 Understanding Prometheus in a Simple Way-Part 3 (For DevOps Beginners)

Grafana Setup & Dashboard Creation (Part-5)— Explained by Raees Yaqoob Qazi

My First Python Program: A Simple Calculator