137
docker
resource_error
ai_generated
true
容器退出代码137(OOMKilled)- 内存限制过低
Container exited with code 137 (OOMKilled) - memory limit too low
ID: docker/container-oom-killed-memory-limit
85%修复率
85%置信度
1证据数
2024-03-15首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| Docker 24.0.7 | active | — | — | — |
| Docker 25.0.3 | active | — | — | — |
| containerd 1.7.13 | active | — | — | — |
根因分析
容器超出了其内存限制,被内核OOM杀手终止,通常是由于--memory或-m设置不足。
English
Container exceeded its memory limit and was killed by the kernel OOM killer, typically due to insufficient --memory or -m setting.
官方文档
https://docs.docker.com/config/containers/resource_constraints/#memory解决方案
-
增加内存限制: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
无效尝试
常见但无效的做法:
-
70% 失败
Rebuilding the image with more layers doesn't change runtime memory limits; the limit is set at container start.
-
60% 失败
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% 失败
Restarting the container without changing memory limits just repeats the same crash.