docker的tomcat镜像
首先编写一个Dockerfile文件
FROM centos
MAINTAINER <>
COPY readme.txt /etc/local/readme.txt
ADD jdk-8u11-linux-x64.tar.gz /usr/local/
ADD apache-tomcat-9.0.27.tar.gz /usr/local/
RUN yum -y install vim
ENV MYPATH /usr/local
WORKDIR $MYPATH
ENV JAVA_HOME /usr/local/jdk1.8.0_11
ENV CLASSPATH $JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
ENV CATALINA_HOME /usr/local/apache-tomcat-9.0.27
ENV CATALINA_BASE /usr/local/apache-tomcat-9.0.27
ENV PATH $PATH:$JAVA_HOME/bin:$CATALINA_HOME/lib:$CATALINA_HOME/bin
EXPOSE 8080
CMD /usr/local/apache-tomcat-9.0.27/bin/startup.sh && tail -F /usr/local/apache-tomcat-9.0.27/bin/logs/catalina.out
镜像编写完 执行 docker build -t diytomcat .这个点不要忘
添加映射端口和地址
docker run -d -p 9091:8080 --name niurentomcat05 -v /home/niu/tomcat/test:/usr/local/apache-tomcat-9.0.27/webapps/test -v /home/niu/tomcat/tomcatlog/:/usr/local/apache-tomcat-9.0.27/logs diytomcat
构建自己的项目进入test mkdir WEB-INF 进入web-inf vim web.xml
并在test下 构建index.jsp文件 最后访问使用宿主机IP地址:端口/test 就可以访问成功了