Docker Exit Code 137 in OpenClaw Running DeepSeek R1
TL;DR
Exit code 137 means the Linux OOM killer terminated the container.
In DeepSeek R1 workloads, this is almost always caused by insufficient available memory.
This is a hardware ceiling, not a Docker bug.
Symptoms
When running DeepSeek R1 in a Docker container, you may observe:
Container exited with code 137
Killed
CUDA out of memory
The container terminates without a stack trace. The application logs stop abruptly. No error message appears from the model itself.
This behavior indicates the process received SIGKILL (signal 9).
Signal Breakdown
Exit code 137 follows this formula:
137 = 128 + 9
- 128: Base offset for signal-based exits
- 9: SIGKILL signal number
SIGKILL cannot be caught, blocked, or ignored. The kernel terminates the process immediately.
In Docker environments, SIGKILL is sent by:
- The Linux OOM killer (most common for DeepSeek R1)
- Docker daemon when memory limits are exceeded
- Manual
docker killcommands
Why It Happens
Three factors contribute to exit code 137 in DeepSeek R1 workloads:
-
DeepSeek R1 requires significant VRAM for model weights. The 8B model in 4-bit quantization requires approximately 6 GB VRAM minimum. Full precision requires substantially more.
-
KV cache expands with context length. Each token in the context window allocates additional memory. A 32K context window can consume 2-4 GB additional VRAM.
-
Docker memory limits amplify the failure when VRAM is exhausted. When GPU memory spills to system RAM, Docker's memory constraints trigger OOM termination.
Fast Check
Before adjusting configuration, verify your hardware limits.
This diagnostic confirms whether your GPU meets minimum requirements for the selected model.
Hard Limits
The following table shows stable VRAM requirements for DeepSeek R1 variants:
| Model | Quantization | Stable VRAM Requirement |
|---|---|---|
| 8B | 4-bit | 12โ16 GB |
| 8B | 8-bit | 16โ20 GB |
| 32B | 4-bit | 24 GB+ |
| 32B | 8-bit | 32 GB+ |
If your GPU has 8GB VRAM, this failure is expected behavior. No configuration adjustment will resolve it.
Confirming OOM as the Cause
Check Docker Events
docker events --filter 'event=oom'
Check System Logs
dmesg | grep -i "out of memory"
dmesg | grep -i "oom"
Check Container Memory Usage
docker stats --no-stream
Expected Output
When OOM is the cause, system logs show:
Out of memory: Killed process 12345 (python) total-vm:32768MB, anon-rss:16384MB
Local Mitigation (Hard Way)
If your hardware meets minimum requirements, these steps may reduce memory pressure:
1. Reduce context window.
Lower the context length from default (typically 4096 or 8192) to 2048 or lower.
OLLAMA_NUM_CTX=2048 ollama run deepseek-r1:8b
2. Lower batch size.
Reduce batch size to 1 if processing multiple requests.
# In vLLM or similar
--max-num-seqs 1
3. Switch to a smaller quantized model.
Use 4-bit quantization instead of 8-bit or full precision.
ollama run deepseek-r1:8b-q4_0
Docker Memory Configuration
Increase Docker Memory Limit
Docker Desktop defaults to 2 GB memory. Increase this value:
docker run --memory=24g --memory-swap=24g your-image
Disable Swap Limit
docker run --memory=24g --memory-swap=-1 your-image
Verify Allocation
docker inspect <container_id> | grep -i memory
Note: Increasing Docker memory allocation does not help if the host system lacks sufficient physical RAM.
Hardware Verdict
When exit code 137 occurs on systems with insufficient VRAM:
Required VRAM: ~14โ16 GB Detected VRAM: 8 GB
Conclusion: No configuration change can bypass physical memory limits.
The gap between required and available memory cannot be closed through software configuration.
Escape Option
For systems that do not meet hardware requirements:
Run DeepSeek R1 on a pre-configured 24GB+ GPU instanceHourly billing. No long-term commitment.
Cloud GPU instances provide:
- 24 GB+ VRAM (RTX 4090, A100)
- 64 GB+ system RAM
- Pre-installed CUDA drivers
- No Docker memory constraints