How do you diagnose an OOM-killed container?
IntermediateProductionResource Limits, Health & Reliability
Answer
docker inspect -f '{{.State.OOMKilled}} {{.State.ExitCode}}' web
dmesg -T | grep -i 'killed process'
docker stats --no-stream web
Check whether the app's heap exceeds the limit (JVM MaxRAMPercentage, Node --max-old-space-size, Go GOMEMLIMIT), then raise the limit or fix the leak. Note that page cache counts toward cgroup memory but is reclaimable.
More on Resource Limits, Health & Reliability
How do you set memory and CPU limits, and what happens when they are exceeded?BeginnerWhat is the difference between `--cpus`, `--cpu-shares` and `--cpuset-cpus`?BeginnerWhat does `--memory-reservation` do?AdvancedWhy do JVM and Node services in containers need explicit memory flags?IntermediateWhat is CPU throttling, and how do you detect it?AdvancedHow do you limit PIDs and open files in a container?Beginner