Inspecting Container Resource Limits via Cgroups

Container Basics On Linux (Namespaces/Cgroups)

Inspecting Container Resource Limits via Cgroups

🧩 The Challenge

You need to verify if your containerized application is actually constrained by the memory limits set in your orchestration manifest. Checking top or free inside the container often reports the host’s total system memory instead of the restricted cgroup limit.

💡 The Fix

Query the memory controller stats directly from the cgroup pseudo-filesystem to see the exact usage and hard limit enforced by the kernel.

cat /sys/fs/cgroup/memory/memory.limit_in_bytes

⚙️ Why It Works

The Linux kernel exposes cgroup metrics through the cgroupfs virtual filesystem, allowing you to bypass container-unaware tools and see the actual constraints applied to the process group.

🚀 Pro-Tip: Use memory.stat in the same directory to see detailed breakdowns of page cache, RSS, and mapped file usage for your specific cgroup.

Linux Tips & Tricks | © ngelinux.com | 7/5/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted