Pin your runaway containers to a strict memory budget

Container Basics On Linux (Namespaces/Cgroups)

Pin your runaway containers to a strict memory budget

🧩 The Challenge

You know that feeling when a runaway process in a container decides to eat every byte of RAM on the host? It’s a total nightmare watching the OOM killer start nuking your production services because one microservice went rogue.

💡 The Fix

Instead of letting containers run wild, you can cap their memory usage directly using cgroup v2, forcing the kernel to throttle them before they can touch your host’s primary memory pool.

echo 512M > /sys/fs/cgroup/my_app_container/memory.max

⚙️ Why It Works

Setting this value tells the Linux kernel exactly how much physical RAM that specific cgroup is allowed to allocate before it has to start swapping or dying.

🚀 Pro-Tip: Check memory.current in the same folder to see exactly how much you’re actually using versus your limit.

Linux Tips & Tricks | © ngelinux.com | 9/13/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted