1.下载jdk和tomcat上传到linux并和Dockerfile放一个目录
2.编写Dockerfile
FROM centos
MAINTAINER ff<adfad@qq.com>
ENV ROOT_PATH /usr/local/
WORKDIR $ROOT_PATH
ADD jdk1.8.tar.gz ./
ADD tomcat9.0.tar.gz ./
RUN ls -lh
ENV JAVA_HOME /usr/local/jdk1.8
ENV CLASSPATH $JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
ENV CATALINA_HOME /usr/local/tomcat
ENV CATALINA_BASE /usr/local/tomcat
ENV PATH $PATH:$JAVA_HOME/bin:$CATALINA_HOME/lib:$CATALINA_HOME/bin
EXPOSE 80
CMD tomcat/bin/startup.sh && tail -F tomcat/logs/catalina.out
注意: tail -F tomcat/logs/catalina.out 是为了设置守护进程,防止开启tomcat后自动关闭容器
3.使用Dockerfile构造镜像
4.运行测试