Although I've read many instructions that appear to do what I'm trying to do, for some reason my Docker containers keep failing. In essence, I'm configuring a Docker container to house a web server and a few daemons. In my Dockerfile, I run a bash script called run-all.sh through CMD to complete the remaining steps. run-all. Sh appears as follows:
service supervisor start
service nginx start
And I start it inside of my Dockerfile as follows:
CMD ["sh", "/root/credentialize_and_run.sh"]
When I run things manually (by connecting to the image with -i -t /bin/bash), I can see that all of the services start up properly. When I run the image, however, it exits after starting up my processes. According to my understanding, for the processes to continue operating indefinitely, the container must remain active. But when I use docker ps -a, I observe:
➜ docker_test docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c7706edc4189 some_name/some_repo:blah "sh /root/run-all.sh 8 minutes ago Exited (0) 8 minutes ago grave_jones
How come? Why is that happening? What's the proper technique to prevent my bash script from exiting? I know I could just add a while loop to the end of it to keep it going.