记录一下docker中tomcat的一个问题,仍未解决

写了个dockerfile,有tomcat和java,但是不管怎么样tomcat都不能在docker启动的时候一起启动。
这是我的dockerfile

FROM centos
MAINTAINER anchao
COPY readme.txt /usr/local/readme.txt
ADD jdk-8u261-linux-x64.tar.gz  /usr/local/
ADD apache-tomcat-9.0.37.tar.gz /usr/local/

RUN yum -y install vim
RUN yum -y install net-tools
ENV MYPATH /usr/local
WORKDIR $MYPATH
ENV JAVA_HOME /usr/local/jdk1.8.0_261
ENV JRE_HOME /usr/local/jdk1.8.0_261
ENV CLASSPATH $JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
ENV CATALINA_HOME /usr/local/apache-tomcat-9.0.37
ENV CATALINA_BASE  /usr/local/apache-tomcat-9.0.37
ENV PATH $JAVA_HOME/bin:$JAVA_HOME:$PATH:$CATALINA_HOME/lib:$CATALINA_HOME/bin
EXPOSE 8080
RUN /usr/local/apache-tomcat-9.0.37/bin/startup.sh
CMD tail -F /url/local/tomcat-9.0.37/bin/logs/catalina.out

这是/tomcat/logs/catalina.out的一部分日志

07-Aug-2020 17:37:53.748 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:             /usr/local/jdk1.8.0_261/jre
usr/local/apache-tomcat-9.0.37/bin/catalina.sh: line 505: /usr/local/jdk1.8.0_261/jre/bin/java: No such file or directory

就很奇怪,已经配置了JAVA_HOME,怎么tomcat中还会有个JAVA HOME呢?
去报错的/bin/catalina.sh中看了一下505行:

 else
    eval $_NOHUP "\"$_RUNJAVA\"" "\"$CATALINA_LOGGING_CONFIG\"" $LOGGING_MANAGER "$JAVA_OPTS" "$CATALINA_OPTS" \
      -D$ENDORSED_PROP="\"$JAVA_ENDORSED_DIRS\"" \
      -classpath "\"$CLASSPATH\"" \
      -Dcatalina.base="\"$CATALINA_BASE\"" \
      -Dcatalina.home="\"$CATALINA_HOME\"" \
      -Djava.io.tmpdir="\"$CATALINA_TMPDIR\"" \
      org.apache.catalina.startup.Bootstrap "$@" start \
      >> "$CATALINA_OUT" 2>&1 "&"

很遗憾 看不懂

因为这个问题,只能在docker启动后再进入docker,手动启动tomcat.很烦.

你可能感兴趣的:(java,tomcat,docker)