According to custom tomcat image file Dokerfile

Ready jdk and tomcat archive

 Write Dockerfile file

# Centos-based mirroring to build
FROM centos
Quan the MAINTAINER on <[email protected]> 
# text copied to the host in the container / usr / local / path
COPY cp.txt /usr/local/cpContainer.txt
# The Tomcat jdk and added to the container
ADD jdk-8u181-linux-x64.tar.gz /usr/local/
ADD apache-tomcat-9.0.30.tar.gz /usr/local/
# Set the log on goal, into the working directory
ENV MYPATH /usr/local
WORKDIR $MYPATH
# Configure environment variables jdk and tomcat
ENV JAVA_HOME /usr/local/jdk1.8.0_181
ENV CLASSPATH $JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
ENV CATALINA_HOME /usr/local/apache-tomcat-9.0.30
ENV CATALINA_BASE /usr/local/apache-tomcat-9.0.30
ENV PATH $PATH:$JAVA_HOME/bin:$CATALINA_HOME/lib:$CATALINA_HOME/bin
# Listening port container operation
EXPOSE 8080
# Specify the default when the container starts execution command
CMD /usr/local/apache-tomcat-9.0.30/bin/startup.sh && tail -F /usr/local/apache-tomcat-9.0.30/bin/logs/catalina.out

Construction of Mirror

 docker build -t mytomcat9 .

 run tomcat mirror newly constructed

docker run -d -p 9000:8080 --name shutomcat9 -v /shuquan/myproject/tomcat9/test:/usr/local/apache-tomcat-9.0.30/webapps/test -v /shuquan/myproject/tomcat9/tomcat9logs/:/usr/local/apache-tomcat-9.0.30/logs --privileged=true mytomcat9

 test

Guess you like

Origin www.cnblogs.com/Lambquan/p/12153660.html