我自己编写的一个tomcat
的Dockerfile
文件,docker build
后在执行docker run
,容器直接退出了,tomcat
并没有开启
FROM debian:lite
LABEL maintainer "jervain@126.com"
#需要jdk-8u121-linux-x64.tar.gz
#需要apache-tomcat-8.0.42.tar.gz
ENV JDK_VERSION 1.8.0_121
ENV TOMCAT_VERSION 8.0.42
ENV CATALINA_HOME /usr/local/tomcat
ENV JAVA_HOME /usr/local/java
ENV SRC_DIR /home/tmp
WORKDIR ${SRC_DIR}
COPY jdk-8u121-linux-x64.tar.gz ${SRC_DIR}
COPY apache-tomcat-8.0.42.tar.gz ${SRC_DIR}
RUN tar -xf jdk-8u121-linux-x64.tar.gz \
&& tar -xf apache-tomcat-8.0.42.tar.gz \
&& mv jdk${JDK_VERSION} ${JAVA_HOME} \
&& mv apache-tomcat-${TOMCAT_VERSION} ${CATALINA_HOME} \
&& export JAVA_HOME="${JAVA_HOME}" \
&& export CLASSPATH=".:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar" \
&& export CATALINA_HOME="${CATALINA_HOME}" \
&& export PATH="$JAVA_HOME/bin:$PATH" \
&& chmod +x ${CATALINA_HOME}/bin/startup.sh \
&& chmod +x ${CATALINA_HOME}/bin/shutdown.sh \
&& rm -rf ./*
ENTRYPOINT [${CATALINA_HOME}"/bin/startup.sh"]
EXPOSE 80 8080
VOLUME [${CATALINA_HOME}"/conf","/var/www/webapps"]
我执行的命令:docker build -t tomcat:8.0.42 .
与docker run -itd tomcat:8.0.42 /bin/bash
执行完成后容器直接退出了,请各位帮我看下Dockerfile有什么问题,不知道是不是因为.sh文件执行完成后就退出了,顺便问下Dockerfile
中ENTRYPOINT
有两种格式sh
与exec
,sh
与exec
的格式具体是怎么用的,能否举个例子
You need a foreground process, such as just tail -f a file or something
The two formats of ENTRYPOINT are sh and exec
sh:curl -s http://www.baidu.com
exec:["curl","-s","http://www.baidu.com"]