1,,下載jdk和tomcat wget https://dlcdn./tomcat/tomcat-8/v8.5.93/bin/apache-tomcat-8.5.93.tar.gz wget https://repo./java/jdk/8u202-b08/jdk-8u202-linux-x64.tar.gz 2,,vim Dockerfile FROM centos:latest MAINTAINER Amadeus # now add java and tomcat support in the container ADD jdk-8u202-linux-x64.tar.gz /usr/local/ ADD apache-tomcat-8.5.93.tar.gz /usr/local/ # configuration of java and tomcat ENV ENV JAVA_HOME /usr/local/jdk1.8.0_202 ENV CLASSPATH $JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar ENV CATALINA_HOME /usr/local/apache-tomcat-8.5.93 ENV PATH $PATH:$JAVA_HOME/bin:$CATALINA_HOME/lib:$CATALINA_HOME/bin # container listener port EXPOSE 8080 # startup web application services by self CMD /usr/local/apache-tomcat-8.5.93/bin/catalina.sh run 3,,build docker鏡像 docker build -t ureport2 . 4. docker run ,映射本地war包路徑和logs日志 docker run --name ureport -d -p 8080:8080 -v /home/ureport/logs:/usr/local/apache-tomcat-8.5.93/logs -v /home/ureport/www:/usr/local/apache-tomcat-8.5.93/webapps --privileged=true ureport2 5. 關(guān)閉防火墻 service firewalld stop 6.如果出現(xiàn)docker network錯(cuò)誤,,執(zhí)行: ?systemctl restart docker |
|