自制tomcat镜像
1.编写dockerfile
FROM centos MAINTAINER raygift@qq.com # 安装vim RUN yum -y install vim net-tools ENV BASEPATH /usr/local WORKDIR $BASEPATH ADD jdk-8u201-linux-x64.tar.gz /usr/local/ ADD apache-tomcat-9.0.6.tar.gz /usr/local/ # 配置java与tomcat环境变量 ENV JAVA_HOME /usr/local/jdk1.8.0_201 ENV CLASSPATH $JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar ENV CATALINA_HOME /usr/local/apache-tomcat-9.0.6 ENV CATALINA_BASE /usr/local/apache-tomcat-9.0.6 ENV PATH $PATH:$JAVA_HOME/bin;$CATALINA_HOME/lib:$CATALINA_HOME/bin EXPOSE 8080 # 启动时运行tomcat #ENTRYPOINT ["$TOMCAT_PATH/bin/startup.sh" ] #CMD ["$TOMCAT_PATH/bin/catalina.sh","run"] CMD /usr/local/apache-tomcat-9.0.6/bin/startup.sh && tail -F /usr/local/apache-tomcat-9.0.6/bin/logs/catalina.out
2.生成镜像
[root@docker dockerfile]# docker build -t tomcat .
3.生成容器
[root@docker ~]# docker run -d -p 9080:8080 --name tomcat -v /tomcat/data:/usr/local/apache-tomcat-9.0.6/webapps/data -v /tomcat/logs:/usr/local/apache-tomcat-9.0.6/logs --privileged=true tomcat9