第一种:
FROM tomcat:8.5
#维护者
MAINTAINER xx@mail.com
#将webapp下的全部删除
RUN rm -rf /usr/local/tomcat/webapps/*
#将target下的xx.war拷贝到/usr/local/tomcat/webapps/下
ADD jenkins.war /usr/local/tomcat/webapps/
RUN chmod 777 /usr/local/tomcat/bin/catalina.sh
#端口
EXPOSE 8080
#设置启动命令
ENTRYPOINT ["/usr/local/tomcat/bin/catalina.sh","run"]
第二种
FROM centos
ARG WAR_FILE
ADD ./apache-tomcat-8.5.47.tar.gz /usr/local/
ADD ./jdk-8u171-linux-x64.tar.gz /usr/local/
COPY ${WAR_FILE} /usr/local/apache-tomcat-8.5.47/webapps/
RUN yum install -y vim
ENV MYPATH /usr/local
WORKDIR $MYPATH
ENV JAVA_HOME=/usr/local/jdk-8u171-linux-x64
ENV JRE_HOME=$JAVA_HOME/jre
ENV CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib:$CLASSPATH
ENV CATALINA_HOME=/usr/local/apache-tomcat-8.5.47
ENV CATALINA_BASH=/usr/local/apache-tomcat-8.5.47
ENV PATH=/sbin:$JAVA_HOME/bin:$PATH:$CATALINA_HOME/lib:$CATALINA_HOME/bin
EXPOSE 8080
CMD /usr/local/tomcat/bin/startup.sh && tail -F /usr/local/apache-tomcat-8.5.47/logs/catalina.out