Skip to content

cgroups: limits, and why exit code 137 happens

Select an icon to see what it is.

Step 6 of 6

CPU limits throttle, they do not kill

When the process uses its whole CPU quota for a period, the kernel pauses it until the next period starts. This shows up as throttling in cpu.stat. The program runs slower, but it is never killed for using too much CPU.

PrevNext

/sys/fs/cgroup/system.slice/docker-a9b8c7d6e5f40312a9b8c7d6e5f40312a9b8c7d6e5f40312a9b8c7d6e5f40312.scope/cpu.stat

nr_periods 1200
nr_throttled 340
throttled_usec 17000000

Try it yourself

Give a container too little memory and watch it get killed.

$ docker run -d --name hog -m 64m python:3-alpine python -c "x = b'a' * 300000000"
$ sleep 5
$ docker inspect --format '{{.State.OOMKilled}} {{.State.ExitCode}}' hog
$ docker rm hog

Quiz

1. What does exit code 137 mean?
2. What happens when a container exceeds its CPU limit?
3. Which file holds the memory limit on cgroup v2?