# 下载tomcat9,jdk8压缩包
# 创建dockerfile文件,文件名为tomcat9, 与tomcat9,jdk8同一个文件下
FROM centos:7
MAINTAINER zhf<492256326@qq.com>
ADD jdk-8u151-linux-x64.tar.gz /usr/local/
ADD apache-tomcat-9.0.69.tar.gz /usr/local/
ENV MYPATH /usr/local
WORKDIR $MYPATH
ENV JAVA_HOME /usr/local/jdk1.8.0_151
ENV CLASSPATH $JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
ENV CATALINA_HOME /usr/local/apache-tomcat-9.0.69
ENV CATALINA_BASE /usr/local/apache-tomcat-9.0.69
ENV PATH $PATH:$JAVA_HOME/bin:$CATALINA_HOME/lib:$CATALINA_HOME/bin
EXPOSE 8080
CMD /usr/local/apache-tomcat-9.0.69/bin/startup.sh && tail -F /usr/local/apache-tomcat-9.0.69/bin/logs/catalina.out
# 构建镜像
docker build -f tomcat9 -t tomcat9:v1 .
# 启动镜像
docker run -d -p 9090:8080 --name tomcat9 -v /home/dockerfile/tomcat/test:/usr/local/apache-tomcat-9.0.69/webapps/test -v /home/dockerfile/tomcat/tomcatlogs:/usr/local/apache-tomcat-9.0.69/logs tomcat9:v1
# 测试访问
http://192.168.5.12:9090/