docker tomcat Log issue

zhangyi picture zhangyi · Jun 28, 2016 · Viewed 13.5k times · Source

Docker container can only to daemon mode: I run catalina.sh to start the tomcat.
But the problem is my log will not appear in catalina.out.

I can look at `docker logs , but this certainly cannot run in a production environment.
I would like to ask how, in production environment, can I have the Tomcat log stored in the document and without the container stopping?

Answer

VonC picture VonC · Jun 28, 2016

If you look at the official tomcat docker image, it runs

CMD ["catalina.sh", "run"]

That is enough to starts tomcat in the foreground, displaying the logs on the console.
But, as you said, that might not populate catalina.out.

An alternative would be:

CMD service tomcat start && tail -f /var/lib/tomcat/logs/catalina.out