-1

I want to interactively execute a Docker container.

I have created it from an image like this

docker create 80597e5353eb

Which outputs an ID:

7372c2d60d513431026a40c50d6f1433e1bc62c57bca4086587193b24c329535 

Then I do docker start on that ID:

docker start 7372c2d60d51

But then, when I try to execute the container:

docker exec -it 7372c2d60d51 /bin/bash 

I get:

Error response from daemon: Container 7372c2d60d513431026a40c50d6f1433e1bc62c57bca4086587193b24c329535 is not running 

Why? I just started the container and it didn't throw any error.

Why is it not started?

bsky
  • 19,326
  • 49
  • 155
  • 270
  • 6
    what's the output of `docker ps -a` (after docker start). Do you see your container. What is the status? if it's not running you can `docker logs containerid`. I would think your missing some env vars or parameters which are necessary to start the container. – lvthillo Dec 22 '16 at 11:47
  • This question has been duplicated many, many times: http://stackoverflow.com/questions/30209776/docker-container-will-automatically-stop-after-docker-run-d http://stackoverflow.com/questions/28212380/why-docker-container-exits-immediately – Nauraushaun Dec 23 '16 at 00:11

1 Answers1

3

1. Why does the Docker Container Exit if there is No Error

There does not need to be an error for a docker container to exit.

The docker container will exit (stop running) if the code running inside finishes executing.

For example, you could have made a container that printed "hello world". As soon as the container prints the hello world phrase, it will exit.

An example of a continuously running application would be a web server listening on a port.

2. Why Does the container Not Start

The container is probably starting. However, the container is stopping quickly.

You use the following command to view all the created containers and what their running states.

docker ps -a

You may see something similar to the below (notice the "Exited" Status): enter image description here

Community
  • 1
  • 1
Peter Hauge
  • 705
  • 6
  • 15
  • 1
    This question has been answered many times already. But I think this might be the best answer going around... – Nauraushaun Dec 23 '16 at 00:12