Container Basics On Linux (Namespaces/Cgroups)
Stop your cgroups from losing track of tasks on restart
đź§© The Challenge
You ever try to limit resource usage for a specific app only to find that it forks a hundred child processes that ignore your memory caps entirely? It’s infuriating when your carefully crafted cgroup just becomes a suggestion rather than a hard limit because you forgot to tell the kernel to handle the sub-processes.
đź’ˇ The Fix
Just flip the memory pressure or process tracking switches in your cgroup configuration to ensure all children inherit the same limitations as their parent. It keeps your runaway processes from eating your entire system memory during a deployment.
echo 1 > /sys/fs/cgroup/memory/your_group_name/memory.use_hierarchy
⚙️ Why It Works
Setting this flag tells the kernel to track the memory usage of child cgroups as part of the parent’s total, preventing those sneaky child processes from slipping under the radar.
🚀 Pro-Tip: Always double check the cgroup version your distro is running, because v2 handles hierarchy by default while v1 makes you manually flip that switch every time.
Linux Tips & Tricks | © ngelinux.com | 7/31/2026
