Docker
●HIGH●Containerization●INTERMEDIATEDocker Container Exit Code 137 (OOM Killed)
A container stops unexpectedly with exit code 137 — the kernel's OOM killer terminated it for using too much memory.
Est. Time
20 minutes
Version
v1.0.0
Updated
8/1/2026
Author
AutoDeploy Team
Tags
Prerequisites
- ✓ Docker installed
- ✓ Access to container logs
Setup Guide
Download guideDocker Container Exit Code 137 (OOM Killed)
Problem
A container stops unexpectedly and `docker inspect` or `docker ps -a` shows exit code 137, meaning the Linux kernel's OOM killer terminated the process for using more memory than allowed.
Symptoms
- Container exits with code 137
- `docker logs` shows no application error before the exit
- `dmesg` or `journalctl -k` shows an oom-kill event for the container's process
- Container restarts repeatedly if using --restart unless-stopped
Root Cause
The container's process exceeded its memory limit (either a Docker --memory limit or the host's available memory), and the kernel's OOM killer sent SIGKILL to reclaim memory.
Solution
1. Confirm it's actually an OOM kill
docker inspect <container> --format='{{.State.OOMKilled}}'2. Check the container's memory limit
docker inspect <container> --format='{{.HostConfig.Memory}}'3. Check current memory usage against the limit
docker stats <container> --no-stream
4. Raise the memory limit if the workload genuinely needs it
docker run -d --memory=1g --memory-swap=1g <image>
5. Or set it in docker-compose.yml
services:
app:
deploy:
resources:
limits:
memory: 1g6. Find and fix real memory leaks
docker exec <container> ps aux --sort=-%mem | head -10
Prevention
- Set explicit memory limits on every container so a leak fails predictably instead of taking down the host
- Add a health check that restarts before memory grows unbounded
- Monitor container memory with cAdvisor, Prometheus node-exporter, or `docker stats`
- Profile memory usage in staging under realistic load before shipping to production
Last updated on 8/1/2026 · Part of the AutoDeploy DevOps Documentation library