Reputation: 1182
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
Upvotes: 1
Views: 1369
Reputation: 17020
The container will exit at the end of the ENTRYPOINT
script you specified here:
ENTRYPOINT ["./TomcatBuild/tomcat/bin/startTenant.sh"]
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:
#!/bin/sh
# Note: I've written this using sh so it works in the busybox container too
# USE the trap if you need to also do manual cleanup after the service is stopped,
# or need to start multiple services in the one container
trap "echo TRAPed signal" HUP INT QUIT TERM
# start service in background here
/usr/sbin/apachectl start
echo "[hit enter key to exit] or run 'docker stop <container>'"
read
# stop service and clean up here
echo "stopping apache"
/usr/sbin/apachectl stop
echo "exited $0"
Another way to keep the container running is to make apache run in the foreground:
ENTRYPOINT ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]
Upvotes: 1
Reputation: 10175
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:
docker ps -a
Now you will be able to find the id / name of your failed container and run the following command to check it's logs:
docker logs [container-id]
Upvotes: 0