Antony Lapitskiy
Antony Lapitskiy

Reputation: 51

Docker Container is not running

Please help. When I want to go into a container is says

Error response from daemon: Container 90599013c666d332ff6560ccde5053d9127e72042ecc3887550aef90fa1d1eac is not running

My DockerFile:

FROM ubuntu:16.04

MAINTAINER Anton Lapitski <[email protected]>

RUN mkdir -p /usr/src/app

WORKDIR /usr/src/app


ADD ./ /usr/src/app

EXPOSE 80

ENTRYPOINT ["/bin/sh", "-c", "/usr/src/app/entry.sh"]

Starting script - start.sh:

sudo docker build -t starter .
sudo docker run -t -v mounted-directory:/usr/src/app/mounted-directory -p 80:80 starter

entry.sh script:

echo "Hello World"
ls -l
pwd
if mountpoint -q /mounted-directory 
then
  echo "mounted"
else
  echo "not mounted"
fi

sudo docker ps -a gives:

CONTAINER ID   IMAGE  COMMAND CREATED STATUS   PORTS   NAMES
90599013c666   starter "/bin/sh -c /usr/src…"   18 minutes ago      Exited (0) 18 minutes ago                       thirsty_wiles

And mosе important:

sudo docker exec -it 90599013c666 bash
Error response from daemon: Container 90599013c666d332ff6560ccde5053d9127e72042ecc3887550aef90fa1d1eac is not running

Please could you tell what I am doing wrong? P.S adding -d flag when running not helped.

Upvotes: 5

Views: 25571

Answers (4)

varun johar
varun johar

Reputation: 41

I tried these two commands and it works:

sudo docker start <container_id>
docker exec -it <containerName> /bin/bash

Upvotes: 1

JasonWayne
JasonWayne

Reputation: 1854

You can try docker start container_id and then docker exec -ti container_id bash for a stopped container.

Upvotes: 3

David Maze
David Maze

Reputation: 159555

Once the ENTRYPOINT completes (in any form), the container exits.

Once the container exits, you can't docker exec into it.

If you want to get a shell on the image you just built to poke around in it, you can

sudo docker run --rm -it --entrypoint /bin/sh starter

To make this slightly easier to run, you might change ENTRYPOINT to CMD in your Dockerfile. (Docker will run the ENTRYPOINT passing the CMD as command-line arguments; or if there is no entrypoint just run the CMD.)

...
RUN chmod +x ./app.sh
CMD ["./app.sh"]

Having done that, you can more easily override the command

sudo docker run --rm -it starter /bin/sh

Upvotes: 8

lependu
lependu

Reputation: 1153

You cannot execute the container, because your ENTRYPOINT script has been finished, and the container stopped. Try this:

  1. Remove the ENTRYPOINT from your Dockerfile
  2. Rebuild the image
  3. run it with sudo docker run -it -v mounted-directory:/usr/src/app/mounted-directory -p 80:80 starter sh

The key is the i flag and the sh at the end of the command.

Upvotes: 0

Related Questions