Interview Prep/Docker/Resource Limits, Health & Reliability

How do you set memory and CPU limits, and what happens when they are exceeded?

BeginnerProductionResource Limits, Health & Reliability
Answer
docker run -d --memory=512m --memory-swap=512m --cpus=1.5 app

Exceeding memory triggers the kernel OOM killer for that cgroup (exit 137, OOMKilled: true). Exceeding CPU only throttles the container (CFS quota), causing latency, not a crash. --memory-swap equal to --memory disables swap.

All Docker questions Roadmap: Docker & containers

More on Resource Limits, Health & Reliability