I'm completely a newbie to docker. I tried to start a exited container like follows,
I listed down all available containers using docker ps -a
. It listed the following:
I entered the following commands to start the container which is in the exited stage and enter into the terminal of that image.
docker start 79b3fa70b51d
docker exec -it 79b3fa70b51d /bin/sh
It is throwing the following error.
FATA[0000] Error response from daemon: Container 79b3fa70b51d is not running
But when I start the container using docker start 79b3fa70b51d
. It throws the container ID as output which is normal if it have everything work normally. I'm not sure what causes this error. Any idea about the causes and suggestions about this would be greatly helpful for me. Thanks in advance.
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:/#