Docker container simultaneous start of multi-service
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 the this image to the run multiple service
# Add service in supervisord.conf from
centos6-ssh
maintainer Edwards bean@gmail.com
run Yum install-y supervisor
run mkdir-p/var/run/sshd
run mkdir-p/var/log/supervisor
ADD supervisord.conf/etc/supervisord.conf
# Expose your port to host
expose
CMD ["/usr/bin/ Supervisord "]
Create supervisord.conf:
[Supervisord]
Nodaemon=true
[program:sshd]
command=/usr/sbin/sshd-d
#add another service#[program:hello]# Command=/bin/bash-c "/root/test.sh"
Made into Image:
Docker build-t Supervisord.
After that, you can add the service cmd startup script via supervisord.conf
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.