Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 843
Antony Lapitskiy Avatar asked Dec 23 '22 02:12

Antony Lapitskiy


1 Answers

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
like image 127
David Maze Avatar answered Dec 28 '22 09:12

David Maze