Docker - Container is not running Docker - Container is not running docker docker

Docker - Container is not running


By default, docker container will exit immediately if you do not have any task running on the container.

To keep the container running in the background, try to run it with --detach (or -d) argument.

For examples:

docker pull debiandocker run -t -d --name my_debian debiane7672d54b0c2docker ps -aCONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMESe7672d54b0c2        debian              "bash"              3 minutes ago       Up 3 minutes                            my_debian#now you can execute command on the containerdocker exec -it my_debian bashroot@e7672d54b0c2:/# 


Container 79b3fa70b51d seems to only do an echo.

That means it starts, echo and then exits immediately.

The next docker exec command wouldn't find it running in order to attach itself to that container and execute any command: it is too late. The container has already exited.

The docker exec command runs a new command in a running container.

The command started using docker exec will only run while the container's primary process (PID 1) is running


If it's not possible to start the main process again (for long enough), there is also the possibility to commit the container to a new image and run a new container from this image. While this is not the usual best practice workflow (the new image is not repeatable), I find it really useful to debug a failing script once in a while.

docker exec -it 6198ef53d943 bashError response from daemon: Container 6198ef53d9431a3f38e8b38d7869940f7fb803afac4a2d599812b8e42419c574 is not runningdocker commit 6198ef53d943sha256:ace7ca65e6e3fdb678d9cdfb33a7a165c510e65c3bc28fecb960ac993c37ef33docker run -it ace7ca65e6e bashroot@72d38a8c787d:/#