Escape the host and see your container memory usage from the outside
Container Basics On Linux (Namespaces/Cgroups)
Escape the host and see your container memory usage from the outside
🧩 The Challenge
You’ve got a container that’s OOM-killing everything in sight, but when you hop inside and run top, the numbers look like a total lie. It’s infuriating when you know the kernel is throttling you, but the container thinks it has all the RAM in the world.
💡 The Fix
Skip the guest-side tools and look at the actual cgroup files managed by the host kernel. This lets you see the truth about memory limits and current usage without the container’s internal lies.
cat /sys/fs/cgroup/memory/docker/<container_id>/memory.usage_in_bytes
cat /sys/fs/cgroup/memory/docker/<container_id>/memory.limit_in_bytes
⚙️ Why It Works
Because these files sit directly in the kernel’s cgroup hierarchy, they report the actual enforcement limits rather than what the application process thinks is available.
🚀 Pro-Tip: Pipe these values through numfmt to actually read the output without doing mental math on bytes.
Linux Tips & Tricks | © ngelinux.com | 10/19/2026
