← Back to DevOps Fixes

Docker Exit Code 137: How to Diagnose and Fix OOM-Killed Containers

Published by NinjaOps Engineering • Verified for Docker & Kubernetes cgroups v2 • Amazon Tag: dev0ps-20
TL;DR: Exit code 137 means your container process received SIGKILL (128 + 9). In 99% of production cases, the Linux kernel Out-Of-Memory (OOM) killer terminated the process because memory consumption hit the container cgroup memory limit.

1. Confirm OOM Kill in 60 Seconds

Run these commands on your host node or container daemon to verify if OOM was the cause:

docker inspect <container_name_or_id> --format '{{.State.OOMKilled}}'

If the output is true, the cgroup limit was breached. You can also inspect the memory allocation limit configured for the container:

docker inspect <container_name_or_id> --format '{{json .HostConfig.Memory}}'

2. Common Causes of Exit Code 137

  1. Unbounded Runtime / JVM Heap: Java applications running inside Docker without container-aware heap flags (e.g. -XX:MaxRAMPercentage=75.0) often allocate memory based on total host RAM rather than the container cgroup limit.
  2. Memory Leaks in Background Workers: Unclosed database connection pools or memory buffering in Node.js/Python workers gradually grow until the cgroup limit is hit.
  3. Node Memory Starvation: If container memory limit is set to 0 (unlimited), the kernel OOM killer terminates containers when the physical host node runs out of RAM.

3. Step-by-Step Resolution

To resolve Exit Code 137 permanently:

⚡ Recommended DevOps Infrastructure & Monitoring Tools

Verified tools for production Kubernetes, Docker, and cloud monitoring:

Note: SaaS program signups pending owner onboarding. Product links route through Amazon tag dev0ps-20 fallbacks.

#AmazonAssociate Disclosure: NinjaOps is an Amazon Associate and earns from qualifying purchases. All book, hardware, and tool links carry Amazon tag dev0ps-20. Full Affiliate Disclosure →