139
docker
runtime_error
ai_generated
partial
container exited with code 139 (segfault)
ID: docker/container-exit-code-139-segfault
70%Fix Rate
82%Confidence
1Evidence
2024-01-10First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| Docker 24.0.7 | active | — | — | — |
| Docker 25.0.0 | active | — | — | — |
| Alpine 3.18 | active | — | — | — |
Root Cause
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.
generic中文
容器内的进程尝试访问不允许的内存,通常由于不兼容的二进制架构、内存损坏或内存限制不足。
Official Documentation
https://docs.docker.com/engine/reference/run/#exit-statusWorkarounds
-
85% success Check binary architecture compatibility: run 'file /path/to/binary' inside container. If mismatch, rebuild for correct architecture (e.g., use --platform linux/amd64).
Check binary architecture compatibility: run 'file /path/to/binary' inside container. If mismatch, rebuild for correct architecture (e.g., use --platform linux/amd64).
-
65% success Increase memory limit and add swap: docker run -m 512m --memory-swap 1g your_image
Increase memory limit and add swap: docker run -m 512m --memory-swap 1g your_image
-
70% success If using gdb or valgrind, debug the segfault: docker run --cap-add=SYS_PTRACE --security-opt seccomp=unconfined your_image gdb /path/to/binary
If using gdb or valgrind, debug the segfault: docker run --cap-add=SYS_PTRACE --security-opt seccomp=unconfined your_image gdb /path/to/binary
中文步骤
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
Dead Ends
Common approaches that don't work:
-
docker run -m 2g your_image
80% fail
Increasing memory limit alone does not fix the underlying segfault cause.
-
docker build --no-cache -t your_image .
70% fail
Rebuilding the image without fixing architecture mismatch still produces the same binary.
-
docker run --user root your_image
90% fail
Running as root does not prevent segfaults caused by memory corruption.