139
docker
runtime_error
ai_generated
partial
容器以代码 139 退出(段错误)
Container exited with code 139 (segfault)
ID: docker/container-exited-139-segfault
72%修复率
83%置信度
1证据数
2023-08-05首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| Docker 24.0.5 | active | — | — | — |
| Linux 5.10.0 | active | — | — | — |
| glibc 2.35 | active | — | — | — |
根因分析
容器内应用程序因段错误崩溃,通常由内存访问违规、栈溢出或不兼容的共享库引起。
English
The application inside the container crashed due to a segmentation fault, often caused by memory access violations, stack overflow, or incompatible shared libraries.
官方文档
https://docs.docker.com/engine/reference/commandline/run/#exit-status解决方案
-
在容器内启用核心转储:添加 '--ulimit core=-1' 并挂载卷以存储核心文件:'docker run --ulimit core=-1 -v /tmp/cores:/cores myapp'。然后使用 gdb 分析:'gdb /path/to/binary /cores/core'。
-
检查不兼容的共享库:在容器内运行 'ldd /usr/bin/myapp'。如果任何库显示 'not found',使用正确的库版本重建镜像。
无效尝试
常见但无效的做法:
-
Increase container memory limit with --memory
60% 失败
Segfault is often not due to memory limit; increasing memory may mask the issue but not fix the root cause.
-
Rebuild the image with --no-cache
70% 失败
Cache invalidation does not fix application logic errors or library incompatibilities.
-
Run container with --security-opt seccomp=unconfined
55% 失败
Unconfined seccomp may allow more syscalls but does not prevent segfaults from application bugs.