Docker - Container is not running
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
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 debian
docker run -t -d --name my_debian debian
e7672d54b0c2
docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e7672d54b0c2 debian "bash" 3 minutes ago Up 3 minutes my_debian
#now you can execute command on the container
docker exec -it my_debian bash
root@e7672d54b0c2:/#