1、下载tomcat和jdk
wget http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-9/v9.0.27/bin/apache-tomcat-9.0.27.tar.gz
wget --http-user=2696671285@qq.com --http-passwd=Oracle123 https://download.oracle.com/otn/java/jdk/8u231-b11/5b13a193868b4bf28bcb45c792fce896/jdk-8u231-linux-x64.tar.gz
2、Dockerfile
FROM ubuntu:18.04 MAINTAINER oy RUN apt-get update && apt-get install -y maven && apt-get install -y git ADD apache-tomcat-9.0.27.tar.gz /usr/local ADD jdk-8u231-linux-x64.tar.gz /usr/local COPY jenkins.war /usr/local/tomcat/webapps #配置java和tomcat的环境变量 ENV JAVA_HOME /usr/local/jdk1.8.0_231 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 # CMD:在启动容器时才执行此行。RUN:构建镜像时就执行此行 CMD java -jar /usr/local/app.jar #容器运行时监听的端口 EXPOSE 8080 #容器启动时运行tomcat CMD ["/usr/local/apache-tomcat-9.0.27/bin/catalina.sh", "run"]
原文地址:https://www.cnblogs.com/xy-ouyang/p/11886383.html
时间: 2024-11-09 08:46:07