When a container dies right after docker run , the usual reaction is to start editing the Dockerfile. Add -it , swap CMD for ENTRYPOINT , try tail -f /dev/null . Most of the time Docker has already told you what went wrong. You just have to read two things: the exit code and the logs .
I reproduced each common failure in a scratch folder so the outputs below are real, not paraphrased. Environment: Docker Engine 26.1.5 (containerd 1.7.24, runc 1.1.15) on Debian 13, using ubuntu:24.04 and python:3.12-slim (Python 3.12.16) images.
For the fuller list of fixes, see this guide on why a Docker container exits immediately and how to fix it .…