How to Keep Docker Container Running After Starting Services? -


i've seen bunch of tutorials seem same thing i'm trying do, reason docker containers exit. basically, i'm setting web-server , few daemons inside docker container. final parts of through bash script called run-all.sh run through cmd in dockerfile. run-all.sh looks this:

service supervisor start service nginx start 

and start inside of dockerfile follows:

cmd ["sh", "/root/credentialize_and_run.sh"] 

i can see services start correctly when run things manually (i.e. getting on image -i -t /bin/bash), , looks runs correctly when run image, exits once finishes starting processes. i'd processes run indefinitely, , far understand, container has keep running happen. nevertheless, when run docker ps -a, see:

➜  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 

what gives? why exiting? know put while loop @ end of bash script keep up, what's right way keep exiting?

this not how should design docker containers.

when designing docker container, you're supposed build such there one process running (i.e. should have 1 container nginx, , 1 supervisord or app it's running); additionally, process should run in foreground.

the container "exit" when process exits (in case, process bash script).


however, if really need (or want) run multiple service in docker container, consider starting "docker base image", uses runit pseudo-init process (runit stay online while nginx , supervisor run), stay in foreground while other processes thing.

they have substantial docs, should able achieve you're trying reasonably easily.


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -