137
docker
resource_error
ai_generated
true
Container exited with code 137 (OOMKilled) - memory limit too low
ID: docker/container-oom-killed-memory-limit
85%Fix Rate
85%Confidence
1Evidence
2024-03-15First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| Docker 24.0.7 | active | — | — | — |
| Docker 25.0.3 | active | — | — | — |
| containerd 1.7.13 | active | — | — | — |
Root Cause
Container exceeded its memory limit and was killed by the kernel OOM killer, typically due to insufficient --memory or -m setting.
generic中文
容器超出了其内存限制,被内核OOM杀手终止,通常是由于--memory或-m设置不足。
Official Documentation
https://docs.docker.com/config/containers/resource_constraints/#memoryWorkarounds
-
85% success Increase the memory limit when running the container: docker run -m 512m --memory-reservation 256m my_image
Increase the memory limit when running the container: docker run -m 512m --memory-reservation 256m my_image
-
80% success Use docker stats to monitor actual usage and set limit 20% higher: docker stats <container_name>
Use docker stats to monitor actual usage and set limit 20% higher: docker stats <container_name>
-
85% success For Docker Compose, add mem_limit in docker-compose.yml: services: app: mem_limit: 512m
For Docker Compose, add mem_limit in docker-compose.yml: services: app: mem_limit: 512m
中文步骤
增加内存限制:docker run -m 512m --memory-reservation 256m my_image
使用docker stats监控实际使用量并设置高20%的限制:docker stats <container_name>
在docker-compose.yml中添加mem_limit:services: app: mem_limit: 512m
Dead Ends
Common approaches that don't work:
-
70% fail
Rebuilding the image with more layers doesn't change runtime memory limits; the limit is set at container start.
-
60% fail
Adding swap space may delay the OOM but doesn't fix the underlying memory exhaustion; the container may still be killed or become unstable.
-
90% fail
Restarting the container without changing memory limits just repeats the same crash.