Docker-compose 3
接著利用compose結合dockerfile,並在dockerfile中安裝和啟動supervisord
Dockerfile
FROM centos:centos7
MAINTAINER Jeff Yang
#RUN yum update -y
RUN yum -y install openssl-devel
ENV MAJOR_PATH /home/apps/IPMI/
ENV INSTALL_PATH /home/install/
ENV CONFIG_PATH /home/apps/DCMS/config/
RUN mkdir -p $MAJOR_PATH
RUN mkdir -p $CONFIG_PATH
RUN mkdir -p $INSTALL_PATH
### Install supervisord manually
#RUN yum -y install python-setuptools python-pip
#RUN easy_install supervisor
COPY setuptools-19.2.tar.gz $INSTALL_PATH
COPY meld3-0.6.5.tar.gz $INSTALL_PATH
COPY elementtree-1.2-20040618.tar.gz $INSTALL_PATH
COPY supervisor-3.1.3.tar.gz $INSTALL_PATH
COPY ipmiutil-2.9.6-1_rhel6.x86_64.rpm $INSTALL_PATH
RUN chmod 700 $INSTALL_PATH/setuptools-19.2.tar.gz && \
tar -zxvf $INSTALL_PATH/setuptools-19.2.tar.gz -C $INSTALL_PATH && \
cd $INSTALL_PATH/setuptools-19.2/ && \
python setup.py install
RUN chmod 700 $INSTALL_PATH/meld3-0.6.5.tar.gz && \
tar -zxvf $INSTALL_PATH/meld3-0.6.5.tar.gz -C $INSTALL_PATH && \
cd $INSTALL_PATH/meld3-0.6.5/ && \
python setup.py install
RUN chmod 700 $INSTALL_PATH/elementtree-1.2-20040618.tar.gz && \
tar -zxvf $INSTALL_PATH/elementtree-1.2-20040618.tar.gz -C $INSTALL_PATH && \
cd $INSTALL_PATH/elementtree-1.2-20040618/ && \
python setup.py install
RUN chmod 700 $INSTALL_PATH/supervisor-3.1.3.tar.gz && \
tar -zxvf $INSTALL_PATH/supervisor-3.1.3.tar.gz -C $INSTALL_PATH && \
cd $INSTALL_PATH/supervisor-3.1.3/ && \
python setup.py install
RUN rpm -i $INSTALL_PATH/ipmiutil-2.9.6-1_rhel6.x86_64.rpm
###
COPY ipmicdc $MAJOR_PATH
RUN chmod 700 $MAJOR_PATH/ipmicdc
COPY ./libs/libipmi.so /usr/lib/
RUN ldconfig
COPY supervisord.conf $MAJOR_PATH
COPY config.ini $MAJOR_PATH
COPY start.sh $MAJOR_PATH
COPY config.json $CONFIG_PATH
RUN ln -s $MAJOR_PATH/supervisord.conf /etc/supervisord.conf
#EXPOSE 9080 9081
CMD $MAJOR_PATH/start.sh
docker-compose.yml
icdc:
container_name: jeff
build: ./
dockerfile: Dockerfile
ports:
- 9080:9080
volumes:
- /home/jeff/code/:/home/code
restart: always
stdin_open: true
tty: true
supervisord.conf
...
[program:ipmicdc]
command=/home/apps/IPMI/ipmicdc %(process_num)d
process_name = %(process_num)d
numprocs=5
autostart=no
autorestart=yes
;stdout_logfile=/home/apps/IPMI/hh.log
[program:ipmi]
command=/home/apps/IPMI/ipmicdc
autostart=yes
autorestart=yes
;stdout_logfile=/home/apps/IPMI/m.log
...
start.sh
#!/bin/sh
/usr/bin/supervisord -c /home/apps/IPMI/supervisord.conf -n
在docker-compose.yml所在目錄下執行
docker-compose up -d
順利的話,supervisord中所設定的程式將會啟動執行