Container not getting started after start command issued

Hi,
I have just started working with Docker installation and practices through CLI. As a first practice, I have executed the command docker run hello-world and in the console it has displayed Hello from Docker and some other lines.

1. Ran docker info command, on the console it printed Containers: 1 and Images: 2 and some other text
2. Ran docker ps -a, on the console it printed:
CONTAINER ID 42977927dd87
IMAGE hello-world:latest
STATUS Exited
and some conetent
3. Ran docker start 42977927dd87, output:
42977927dd87
4. Ran docker ps command, on the console it just printed the field name as CONTAINER ID but no container id displayed.
5. Again I have ran the command docker ps -a, on the console it printed:
CONTAINER ID 42977927dd87
IMAGE hello-world:latest
STATUS Exited
and some content

Please answer my queries:

  1. Why container is not started after start command? If it started the container ID has to be displayed after docker ps command right?
  2. Why it is showing the status as Exited in docker ps -a command output.
  3. Why Images are showing as 2 in the docker info command output?

Thanks in advance,
Vish

Hi Vish,

I recommend working through the user guide starting from this section: http://docs.docker.com/userguide/#dockerizing-applications-a-hello-world - The docker ps and docker start commands are explained in more detail in the user guide compared to the quick intro.

Thanks,

Jerry

1& 2. The hello-world image just outputs some text and then exits. It does not run as a service. So by the time you start the container, then run docker ps -a you are in fact seeing the container that has exited.

  1. What does docker images output?

use "-i "and " -t "

https://docs.docker.com/reference/run/

1 Like

It also depends on how you are creating your images and how the containers are being created. Are you using a Dockerfile? If yes, are you running some other service in it? If yes, do you have a CMD section? If yes, make sure you include the “FOREGROUND” keyword in your CMD section to have your container always up and running.
Do feel free to correct me if I am wrong. Even I am new to this.

Docker has some pathetic documentation.
docker documentations just says start comamnd will start the container. why it stops, and when it stops not explained.
One liner is sufficient for all docker documentation.
I hope we have a better container tool in future.

Did you find any solution,
I am also struggling to find the option where start command runs the container in background and doesnot kill it