Tomcat 构建
FROM ubuntu:18.04
ADD ./soft/apache-tomcat-8.5.65.tar.gz /usr/
ADD ./soft/jdk-8u202-linux-x64.tar.gz /usr/
ADD ./tomcat.sh /opt/
RUN chmod a+x /opt/tomcat.sh &&
mv /usr/apache-tomcat-8.5.65 /usr/tomcat &&
mv /usr/jdk1.8.0_202 /usr/java
RUN echo "export JAVA_HOME=/usr/java" >> /etc/profile &&
echo "export JRE_HOME=/usr/java/jre" >> /etc/profile &&
echo "PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin" >> /etc/profile &&
echo "export PATH" >> /etc/profile &&
source /etc/profile
ENTRYPOINT bash /opt/tomcat.sh
#!/bin/bash which java if [ $? != 0 ]; then echo "JAVA_HOME=/usr/java" >> /etc/profile echo "JRE_HOME=/usr/java/jre" >> /etc/profile echo "PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin" >> /etc/profile echo "export PATH" >> /etc/profile source /etc/profile fi /bin/sh /usr/tomcat/bin/catalina.sh run
注意:这里为什么不直接用startup.sh 去执行,是因为sh 不支持source 动作,所以需要通过sh 去执行另外一个启动脚本。