0

I tried to make container using this dockerfile. sorry, first time create post in stack, so just upload the photo..

I run it with using this :

docker run -dit -p 8014:80 --name webserver7test2 webserver even try without -it

run successfull. if the container stop and I try to start it again but the container always exit immediately. enter image description here

try advice from this post but failed with this log appear.

enter image description here

really appreciate if you can help me

Fabrizio
  • 7,603
  • 6
  • 44
  • 104
  • Could you post your Dockerfile? so we can see what command you are using and what process you are trying to run to keep the container alive. – Juan Sep 14 '17 at 19:33
  • Remove the `-d` flag and then run. This will show you what happens in the container. Also make sure the command that runs doesn't exit or launch a background process. You need to make sure the program runs in foreground – Tarun Lalwani Sep 14 '17 at 20:41

2 Answers2

0

The image shows that your container exited with code 0. That means there was no error and your start command ran and then finished execution.

Make sure you have CMD <webserver-start-script> inside your Dockerfile and it should not exit until your container is running. If it exits, docker thinks container is done and stops it.

Tejas
  • 284
  • 2
  • 8
0

You docker is exiting because there is no process in the foreground. Docker will exit if no process is found in the foreground. Try adding tail -f /dev/null to the last line of your Dockerfile.

Bill Cheng
  • 732
  • 1
  • 8
  • 15