brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: OOMKilled in docker inspect tells you the container ran out of memory

Docker
~/tips/tip-docker-inspect-oomkilled

docker inspect --format '{{.State.ExitCode}} OOMKilled={{.State.OOMKilled}}' myapp

Find out whether exit code 137 came from the memory limit.

A container that keeps dying with exit code 137 was killed with SIGKILL. That can be a docker kill, a stop that timed out, or the kernel’s out of memory killer. Docker records which one.

docker inspect --format '{{.State.ExitCode}} OOMKilled={{.State.OOMKilled}}' myapp

A result like 137 OOMKilled=true means the container hit its memory limit, or the host ran out, and the kernel killed it. The app’s own log usually ends mid sentence, with no error, which is why this is so confusing at first.

Real fixes: raise the limit with --memory or Compose’s deploy.resources.limits.memory, give the app its own memory setting (Java’s heap size is a classic), or find out why it suddenly needs more.

The flag describes the most recent exit, so I would check it soon after the crash. docker events --filter event=oom catches it live. When the host itself runs out, the kernel may pick a process in a container without a limit, so also look at dmesg on the host for the out of memory lines.

Further reading: docker container inspect, Resource constraints: memory

More Docker tips ONBUILD RUN /usr/local/bin/python-build --dir /app/src SHELL ["/bin/bash", "-c"] docker commit <container> myname/testimage:version3 docker import /path/to/exampleimage.tgz docker compose events All Docker tips (192) All topics

Link