Peer into the abyss of your container cgroups
Container Basics On Linux (Namespaces/Cgroups)
Peer into the abyss of your container cgroups
🧩 The Challenge
Trying to figure out why a container keeps getting killed by the OOM killer when your monitoring dashboard claims it’s barely using any memory is infuriating. I’ve wasted hours staring at dashboards that average things out while the kernel is busy nuking processes behind my back.
💡 The Fix
Dig straight into the cgroup filesystem on the host to see the raw, unvarnished truth of what the kernel is actually tracking for that specific container. It cuts through the noise of what your orchestrator thinks is happening.
cat /sys/fs/cgroup/memory/docker/<container_id>/memory.stat | grep -E "cache|rss|usage"
⚙️ Why It Works
Since the kernel exposes the cgroup hierarchy as a pseudo-filesystem, you can just cat the stats files directly to see the counters the OOM killer cares about. This bypasses the lag and aggregation you get from high-level management tools.
🚀 Pro-Tip: Use the -v flag with grep if you want to filter out the zeroes and focus only on the metrics actually changing.
Linux Tips & Tricks | © ngelinux.com | 9/12/2026
