yum安装supervisord
# wget https://mirrors.aliyun.com/epel/6/x86_64/Packages/p/python-meld3-0.6.7-1.el6.x86_64.rpm
# wget https://mirrors.aliyun.com/epel/6/x86_64/Packages/s/supervisor-2.1-9.el6.noarch.rpm

配置dockerfile
# cat Dockerfile
FROM centos:6.8

RUN mkdir /tomcat
RUN yum -y install wget lrzsz && cd /tomcat && wget http://mytest.com/tomcat/jdk1.6.0_45.tar.gz -P /tomcat && tar zxvf jdk1.6.0_45.tar.gz -C /tomcat

WORKDIR /tomcat
ADD python-meld3-0.6.7-1.el6.x86_64.rpm /usr/local/src/
ADD supervisor-2.1-9.el6.noarch.rpm /usr/local/src/
RUN rpm -ihv /usr/local/src/python-meld3-0.6.7-1.el6.x86_64.rpm && yum -y install /usr/local/src/supervisor-2.1-9.el6.noarch.rpm
ADD apache-tomcat-6.0.35 /tomcat/apache-tomcat-6.0.35
ADD logstash-2.4.1.tgz /tomcat/
ADD start.sh /tomcat/start.sh
ADD supervisord.conf /etc/supervisord.conf
RUN cp /etc/hosts /etc/hosts.temp
RUN sed -i "s/.*$(hostname)/$HOST $(hostname)/" /etc/hosts.temp
RUN cat /etc/hosts.temp > /etc/hosts
RUN \cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

EXPOSE 8080
CMD ["/usr/bin/supervisord","-c","/etc/supervisord.conf"]

创建supervisord配置文件
# cat supervisord.conf
[program:tomcat]
command=/tomcat/apache-tomcat-6.0.35/bin/catalina.sh run

[program:logstash]
environment=JAVA_HOME="/tomcat/logstash-2.4.1/jdk/",JAVA_BIN="/tomcat/logstash-2.4.1/jdk/bin"
command=/tomcat/logstash-2.4.1/bin/logstash --config /tomcat/logstash-2.4.1/conf/logstash.conf --log /tomcat/logstash-2.4.1/log/logstash.log

[supervisord]
nodaemon=true
[supervisorctl]

配置tomcat的java环境
# head apache-tomcat-6.0.35/bin/catalina.sh
#!/bin/sh
#export JAVA_OPTS='-Xms2048m -Xmx4096m -XX:PermSize=1024m -XX:MaxPermSize=1024m'
JAVA_HOME=/tomcat/jdk1.6.0_45
PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
TOMCAT_HOME=/tomcat/apache-tomcat-6.0.35
CLASSPATH=.$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/lib/tools.jar
PATH=$PATH:$TOMCAT_HOME/bin
JAVA_OPTS="$JAVA_OPTS -Xms512M -Xmx512M -Xmn256M -XX:PermSize=200M -XX:MaxPermSize=64M"
JAVA_OPTS="$JAVA_OPTS -XX:SurvivorRatio=8 -XX:MaxTenuringThreshold=10 -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -XX:+CMSParallelRemarkEnabled -XX:CMSInitiatingOccupancyFraction=80 -XX:+UseCMSInitiatingOccupancyOnly -XX:SoftRefLRUPolicyMSPerMB=0 -XX:CMSFullGCsBeforeCompaction=0"
# Licensed to the Apache Software Foundation (ASF) under one or more

配置logstash的java环境
# head logstash-2.4.1/bin/logstash
#!/bin/sh
JAVA_HOME="/tomcat/logstash-2.4.1/jdk/"