I have installed docker on Windows machine. I want to run tomcat setup from my Windows machine to Docker container.
My dockerfile is as follows:
FROM openjdk:8-jre-alpine3.9
RUN mkdir -p C:/Users/project/Y
COPY TQ C:/Users/project/Y
WORKDIR C:/Users/project/Y
ENV JAVA_HOME C:/Java8/jdk1.8
#ENV PATH $PATH:$JAVA_HOME/bin
ENV TOMCAT_HOME ./TomcatB/tomcat
ENV TOMCAT_BASE ./TomcatB/tomcatBase
ENV CALD_CONFIG_DIR ./TomcatBuild/config
EXPOSE 8080
RUN sed -i 's/port="0060"/port="8080"/' ./TomcatBuild/config/server.properties
ENTRYPOINT ["./TomcatBuild/tomcat/bin/startTenant.sh"]
Image gets created here , but running command : "docker run -d project T" or docker run -p 8080:8080 -d project T** starts container which Exists immediately**.
Tomcat is running.
Why Container gets EXITED immediately?
loadProperties()
{
if [ "$DEBUG" = "true" ]; then
echo "server.properties=${CALD_CONFIG_DIR}/${TENANT_ID}/server.properties"
fi
. ${CALD_CONFIG_DIR}/${TENANT_ID}/server.properties
status=$?
if [ $status -ne 0 ]; then
echo "Error: The property loading phase failed. Unable to read ${CALD_CONFIG_DIR}/${TENANT_ID}/server.properties so halting with status=1"
exit 1
fi
}
validateProperties()
{
if [ "${TomcatListenPort}" = "" ]; then
echo "Error: TomcatListenPort is not defined in server.properties. T
2
Answers
Look man, we can’t tell exactly why is this container crashing from your side, I would recommend to start by looking at the logs that might point you out on why the container failed! command to list all containers, including failed / crashed containers:
Now you will be able to find the id / name of your failed container and run the following command to check it’s logs:
The container will exit at the end of the
ENTRYPOINT
script you specified here:What is the contents of the startTenant.sh script?
If your script needs to stay working, the script will need to stay wait until the container is stopped for some reason.
The docker documentation has an example of how to keep Apache Tomcat running. The script can pause while awaiting input:
Another way to keep the container running is to make apache run in the foreground: