Exit Code 137
The containerized process was forcefully terminated by a SIGKILL (signal 9) signal from the host, typically due to memory exhaustion.
Usually happens because:
- ☑ Process consumed more memory than allocated
- ☑ Container ignored SIGTERM and was force-stopped
- ☑ Manual docker kill command executed
🔍 Quick Checklist:
What is Exit Code 137?
Exit code 137 is returned when the container process terminates due to receiving Unix signal 9 (SIGKILL). This is computed as 128 (offset for signal terminations) + 9 (SIGKILL). The most common causes are memory exhaustion (OOM), manual container termination via docker kill, or a docker stop command that exceeded its 10-second grace timeout.
Common Causes
- Kernel Out of Memory (OOM) Killer: The host operating system terminated the container process because it ran out of memory.
- Docker Stop timeout: The container process took too long to shutdown, forcing a SIGKILL from Docker.
- Manual Docker Kill: A developer executed the 'docker kill' command to stop the container immediately.
| Cause | Frequency |
|---|---|
| Kernel Out of Memory (OOM) event | ⭐⭐⭐⭐⭐ |
| Docker stop command timeout | ⭐⭐⭐⭐ |
| Manual docker kill command | ⭐⭐ |
Common Mistakes
- Assuming exit code 137 is always caused by OOM (it also occurs when a docker stop times out and force-kills the container).
How to Fix
Docker Operations & Verification
Inspect container exit code history.
docker ps -a --filter "exited=137"Platform Specific Fixes
Scan kernel logs for OOM and SIGKILL signals.
sudo journalctl -k | grep -i -E 'oom|kill'Best Practices
- Verify container entrypoints propagate OS termination signals correctly to child processes.
Frequently Asked Questions (FAQ)
Q: What does exit code 137 mean?
It indicates that the container was stopped forcefully by a SIGKILL (signal 9) signal.
Q: How is this different from exit code 143?
Exit code 143 corresponds to SIGTERM (128 + 15), which represents a graceful shutdown request. Exit code 137 is a force kill (SIGKILL).
Q: How do I inspect why a container exited with 137?
Run 'docker inspect <container_id>' and check the 'OOMKilled' flag.
Q: How do I increase memory in compose?
Set limits: resources.limits.memory inside the deploy block.