Container Resource Monitoring with Docker stats

TechOps Examples

Hey — It's Govardhana MK 👋

Along with a use case deep dive, we identify the remote job opportunities, top news, tools, and articles in the TechOps industry.

IN TODAY'S EDITION

🧠 Use Case
  • Container Resource Monitoring with Docker stats

🚀 Top News

👀 Remote Jobs

📚️ Resources

📢 Reddit Threads

🛠️ TOOL OF THE DAY

gama - A new terminal-based UI tool, streamlines GitHub Actions workflow management by allowing users to list, trigger, and monitor workflows directly from the terminal.

Features a live mode for automatic status updates.

🧠 USE CASE

Container Resource Monitoring with Docker stats

Most Docker users are missing out on native monitoring features and running behind shiny expensive tools.

Of course, better tools are not bad, but when you've got so much valuable information within Docker itself, it's a mistake to overlook gems like docker stats

Need to check container CPU, memory, and network usage? Use docker stats

It saves cost, simplifies debugging, and helps with capacity planning without relying on external monitoring.

when you run docker stats, you'll see an output similar to this:

Every column in the docker stats output tells a story about your container's resource usage. Let's break them down:

1. CPU % (CPU Usage)
  • Represents the % of total CPU resources used by the container.

  • Can exceed 100% in multi-core systems (e.g., 200% means 2 full cores).

Usage Levels:
 <10% → Low usage, mostly idle
⚠️ 10-50% → Moderate usage, normal for many workloads
🚨 >80% → High CPU usage, check for bottlenecks

💡 Limit CPU usage when running a container:

docker run --cpus="1.5" your_container

2. MEM USAGE / LIMIT (Memory Usage and Limits)
  • MEM USAGE → The actual memory being used by the container.

  • MEM LIMIT → The maximum memory allocated for the container (if set). If no limit is defined, it shows the total host memory.

3. MEM % (Memory Percentage)

Memory usage relative to its limit.

Formula: Memory % = (MEM USAGE / MEM LIMIT) * 100

 <50% → Optimal
⚠️ 50-80% → Keep an eye on it
🚨 >80% → May trigger OOM events

4. NET I/O (Network Traffic)
  • Shows data received and transmitted by the container.

  • Useful for detecting unexpected spikes or bottlenecks.

 Low network activity? Your app might be idle.
⚠️ High network I/O? Check for excessive data transfer or possible leaks.

💡 Use tcpdump inside the container to inspect traffic

docker exec -it <container_id> tcpdump -i eth0

5. BLOCK I/O (Disk Read/Write Operations)
  • First value: Data read by the container

  • Second value: Data written by the container

 <10MB → Low, expected for lightweight apps.
⚠️ 10MB - 500MB → Moderate, common for logging, caching.
🚨 500MB - 5GB → High, likely frequent file operations or active databases.
🔥 >5GB → Excessive! Check for inefficient logging, batch jobs.

💡 Fix High Disk I/O:

  • Excessive logs? Limit log file size

    docker run --log-opt max-size=10m --log-opt max-file=3 my_container

  • Database-heavy? Add caching (Redis) & optimize queries.

6. PIDS (Number of Processes in the Container)

Represents active processes inside the container.

 1-10 → Simple applications
⚠️ 10-50 → Moderate complexity
🚨 >50 → Possible process leaks

💡 Limit process count per container:

docker run --pids-limit=50 your_container

By default, docker stats command streams the resource usage metrics for all running containers.

To monitor on a specific container:

docker stats <container_id_or_name>

To filter containers by name pattern:

docker stats --filter "name=techops-*"

docker stats gives you instant insights into your containers without any additional setup.

Before rushing to paid monitoring solutions, make sure you're fully leveraging the built in power of Docker itself.

Looking to promote your company, product, service, or event to 47,000+ Cloud Native Professionals? Let's work together.