## download centos7 Mirror # the FROM CentOS: 7.4.1708 the FROM the Java: openjdk-8 -alpine ## of MAINTAINER by Will wangzeng # install en_US.UTF- 8 and configure the environment # RUN locale-Gen en_US.UTF-8 # ENV LANG en_US . 8-.UTF # ENV the LANGUAGE the en_US: EN # ENV the LC_ALL the en_US.UTF. 8- ## mounted JDK the RUN mkdir / usr / Soft # the RUN mkdir / usr / local / JDK # COPY JDK-8u241-Linux-x64.tar.gz /usr/soft/jdk-8u241-linux-x64.tar.gz # RUN tar xvf /usr/soft/jdk-8u241-linux-x64.tar.gz -C /usr/local/jdk #RUN rm -rf /usr/soft/jdk-8u241-linux-x64.tar.gz ##安装tomcat RUN mkdir -p /usr/local/tomcat COPY apache-tomcat-7.0.100.tar.gz /usr/soft/apache-tomcat-7.0.100.tar.gz RUN tar xvf /usr/soft/apache-tomcat-7.0.100.tar.gz -C /usr/local/tomcat RUN rm -rf /usr/soft/apache-tomcat-7.0.100.tar.gz ##设置环境变量 #ENV JAVA_HOME /usr/local/jdk/jdk1.8.0_241 ENV CATALINA_HOME /usr/local/tomcat/apache-tomcat-7.0.100 #ENV PATH $PATH:$JAVA_HOME/bin:$CATCHA_HOME/bin ENV the PATH $ the PATH: $ CATCHA_HOME / bin ## packaged items copied to the tomcat webapps directory ## COPY xxx /usr/local/tomcat/apache-tomcat-7.0.100 / webapps internal service port ## open EXPOSE 8080 ## final start sshd process, to prevent the container starts after missing ## CMD / usr / sbin / sshd -D CMD [ "./usr/local/tomcat/apache-tomcat-7.0.100/bin/catalina.sh", "RUN "]
build:docker build --rm=true --no-cache=false -t java8tomcat7:1.0 .
运行:docker run -it -d --name tomcat7 -p 8099:8080 java8tomcat7
Mount directory run: docker run -it -d --name tomcat8 -p 8089: 8080 -v / root / tomcat / webapps: / usr / local / tomcat / webapps tomcat
Reference: https://www.jianshu.com/p/65b955f7864e