Docker & Containers (50 Qs)•Part 3: Advanced Internals, Scale & Production Security (Senior / Lead)
Memory Limits and the Linux Out-Of-Memory (OOM) Killer.
senior LevelSecurity & Auth
In Simple Words:
If a container has no memory limit (--memory), a memory leak will consume all host RAM, prompting the Linux kernel OOM Killer to terminate critical system processes!
- Set hard limits:
--memory="2g" --memory-swap="2g". - If the container exceeds 2GB, the kernel OOM Killer terminates only the container process (
Exit Code 137), protecting the rest of the host infrastructure.