CodexBloom - Programming Q&A Platform

Ubuntu 22.04 - Docker Container scenarios to Start with 'exit code 139' on Custom Build

👀 Views: 29 💬 Answers: 1 📅 Created: 2025-06-10
docker ubuntu segmentation-fault Python

I'm working with an scenario with a Docker container that won't start on my Ubuntu 22.04 server. The container is based on a custom image built from a Dockerfile, but when I try to run it, I get the behavior 'Container exited with code 139'. This seems to indicate a segmentation fault, but I'm not sure how to diagnose the scenario properly. Here's a simplified version of my Dockerfile: ```Dockerfile FROM ubuntu:22.04 RUN apt-get update && apt-get install -y \ build-essential \ python3-pip \ && rm -rf /var/lib/apt/lists/* COPY ./my_script.py /app/my_script.py CMD ["python3", "/app/my_script.py"] ``` The `my_script.py` file that I'm trying to run is a simple Python script that processes some data. Here's a snippet of it: ```python import numpy as np # Simulating some heavy computation data = np.random.rand(10000, 10000) result = np.linalg.inv(data) print("Computation done!") ``` I've verified that the script runs without scenario on my local machine and also directly on the server. I’ve tried running the container with `docker run --rm -it --cap-add=SYS_PTRACE my_custom_image` to see if I could attach a debugger, but it doesn't give me any additional information. To troubleshoot further, I checked the logs with `docker logs <container_id>`, but there's no helpful output. I've also ensured that I have the latest version of Docker installed (20.10.17) and that my kernel is up to date, but nothing seems to resolve the segmentation fault. Does anyone have experience dealing with segmentation faults within Docker containers on Ubuntu? What steps can I take to diagnose or fix this scenario? This is for a REST API running on Debian. Any advice would be much appreciated.