Docker container simultaneous start of multi-service

Source: Internet
Author: User
Tags mkdir ssh rabbitmq

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.