Pinpoint which container is actually hogging the CPU cycles
Container Basics On Linux (Namespaces/Cgroups)
Pinpoint which container is actually hogging the CPU cycles
🧩 The Challenge
You know that feeling when the server load average hits double digits, but top isn’t showing you which specific container is the culprit? I’ve wasted half a morning hunting down a rogue microservice because it was hiding behind the generic “docker-proxy” process name.
💡 The Fix
Peek directly into the cgroup filesystem to see raw CPU usage stats per container. It bypasses the confusion of standard process viewers and shows you exactly who is burning cycles.
cat /sys/fs/cgroup/cpu/docker/$(docker inspect --format='{{.Id}}' <container_name_or_id>)/cpu.stat
⚙️ Why It Works
Since the kernel tracks resource usage through cgroup hierarchies, reading the stat file gives you the unfiltered truth about usage ticks. It’s way more accurate than what you get from a top-level process list that rolls everything into one misleading bucket.
🚀 Pro-Tip: Pipe it into awk if you want to turn those raw nanoseconds into something you can actually read.
Linux Tips & Tricks | © ngelinux.com | 10/27/2026
