I'm running tomcat in docker, but I can't see the logs. They are written to various log files under tomcat/logs, but I can't see them when tomcat is running in a docker container.
Here is my Dockerfile
FROM tomcat:7-jre8
COPY target/MYAPP.war /usr/local/tomcat/webapps/MYAPP.war
RUN ["/usr/local/tomcat/bin/catalina.sh", "start"]
This is how I build image & start container from it:
docker build -t MYAPP .
docker run -it --rm -p 8080:8080 --name MYAPP MYAPP
My app creates log file: /var/log/MYAPP.log after tomcat deploys MYAPP.war
How should I amend Dockerfile and which command should I use to run it ("docker run ...") so that right after starting the container MYAPP using the oneliner "docker run -it --rm -p 8080:8080 --name MYAPP MYAPP" the contents of /var/log/MYAPP.log would be printed to stdout?
I tried to add to Dockerfile the command below but it didn't help.
CMD tail -f /usr/local/MYAPP.log
You seem to be confused about the different between
RUNandCMD.The
RUNdirective is used to run commands during the build process. It is never executed in a container. When you write......this means that during the
docker buildprocess, Docker will start tomcat, but will immediately kill it and continue to build your image.Only the
CMDandENTRYPOINTdirectives define commands that will be run when you boot an image withdocker run. So possibly you want something like: