Docker Container start multi-service at the same time
Reprint please specify from: http://blog.csdn.net/wsscy2004
Yesterday I stepped on a sinkhole, I have a basic mirror centos6.5+ssh, is through dockerfile build, using the cmd command to start SSH.
Through centos6.5+ssh mirroring, I want to build a rabbitmq mirror, dockerfile cmd to start the RABBITMQ service. Although I know that there is only one cmd in dockerfile, I do not expect to create another image and inherit the cmd from image.
With Docker's command inspect you can see that CMD has been replaced.
" CMD " : [ /usr/bin/supervisord"],
Below to get to the point, how to start multiple services at the same time, mainly in the following ways
Supervisor
Supervisor is a tool for monitoring processes under Linux, starting all services through supervisor.
Create Dockerfile:
# Use this image to run multiple service# add serviceinchsupervisord.conf from CENTOS6-SSHmaintainer [email protected]runYum Install-y Supervisorrunmkdir-p/var/run/Sshdrunmkdir-p/var/log/Supervisoradd supervisord.conf/etc/supervisord.conf# expose your port to Hostexpose A theCMD ["/usr/bin/supervisord"]
Create supervisord.conf:
[Supervisord]nodaemon=true [Program:sshd]command=/usr/sbin/sshd-D #add Another Service#[program:hello] #command"/root/test.sh"
Made into Image:
Docker build-t Supervisord.
After that, you can add services through supervisord.conf.
CMD Startup Scripts
Use the cmd command to start the script by encapsulating all the services to be started into a single script. But better Supervisord, not recommended.
Docker container simultaneous start of multi-service supervisor