Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debug Docker that quits immediately?

Tags:

python

docker

I am following the official docker tutorial: https://docs.docker.com/get-started/part2/#build-the-app

I can successfully build the Docker image (after creating the Dockerfile, app.py and requirements.txt) and see it:

docker build -t friendlyhello .
docker ps -a

However, it quits immediately when running

docker run -p 4000:80 friendlyhello

I cannot find the way to find why it did not work

1) "docker ps -a" - says the container exited 2) docker logs "container name" returns no information about logs 3) I can attach the shell to it:

docker run  -p 4000:80 friendlyhello /bin/sh

but I did not manage to find (grep) any logging information there (in /var/log) 4) attaching foreground and detached mode with -t and -d did not help

What else could I do?

like image 211
Draif Kroneg Avatar asked Aug 30 '26 08:08

Draif Kroneg


1 Answers

Note: a docker exec on an exited (stopped) container should not be possible (see moby issue 30361)

docker logs and docker inspect on a stopped container should still be possible, but docker exec indeed not.

You should see

Error response from daemon: Container a21... is not running

So a docker inspect of the image you are running should reveal the entrypoint and cmd, as in this answer.
The normal behavior is the one described in this answer.

like image 198
VonC Avatar answered Sep 02 '26 12:09

VonC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!