139
docker
runtime_error
ai_generated
partial
容器以代码 139 退出(段错误)
container exited with code 139 (segfault)
ID: docker/container-exit-code-139-segfault
70%修复率
82%置信度
1证据数
2024-01-10首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| Docker 24.0.7 | active | — | — | — |
| Docker 25.0.0 | active | — | — | — |
| Alpine 3.18 | active | — | — | — |
根因分析
容器内的进程尝试访问不允许的内存,通常由于不兼容的二进制架构、内存损坏或内存限制不足。
English
A process inside the container attempted to access memory it was not allowed to, often due to incompatible binary architecture, corrupted memory, or insufficient memory limits.
官方文档
https://docs.docker.com/engine/reference/run/#exit-status解决方案
-
Check binary architecture compatibility: run 'file /path/to/binary' inside container. If mismatch, rebuild for correct architecture (e.g., use --platform linux/amd64).
-
Increase memory limit and add swap: docker run -m 512m --memory-swap 1g your_image
-
If using gdb or valgrind, debug the segfault: docker run --cap-add=SYS_PTRACE --security-opt seccomp=unconfined your_image gdb /path/to/binary
无效尝试
常见但无效的做法:
-
docker run -m 2g your_image
80% 失败
Increasing memory limit alone does not fix the underlying segfault cause.
-
docker build --no-cache -t your_image .
70% 失败
Rebuilding the image without fixing architecture mismatch still produces the same binary.
-
docker run --user root your_image
90% 失败
Running as root does not prevent segfaults caused by memory corruption.