tomcat7 fail to start inside Ubuntu Docker container tomcat7 fail to start inside Ubuntu Docker container docker docker

tomcat7 fail to start inside Ubuntu Docker container


The solution

The tomcat startup script needs some special privileges. Concrete it needs to check all running processes, to verify itself is running. You can give the Docker container following privilege in order to make the tomcat start script exiting with success:

sudo docker run --cap-add SYS_PTRACE -it ubuntu bash

The important option is --cap-add SYS_PTRACE, all other options may vary. There is (at least one) an issue discussing this problem on docker github:

https://github.com/docker/docker/issues/6800

subsequent problems

Nevertheless I've found no way to set this privilege for the docker build of an image. My ultimate goal is to run a docker build which executes an Ansible playbook inside. The build just fails because of the service start, which I won't take out of the playbook. I'll make further investigations, but possible solutions are welcome.


This article reports the same error (for Tomcat8, but it should apply for Tomcat7 as well):

I have no idea why, but it seems Tomcat 8 on Ubuntu is not configured in any meaningful way. Everything is available but we need some symbolic links here and there as well as creating the temp directory. This translates into the following instruction in the Dockerfile:

RUN ln -s /var/lib/tomcat8/common $CATALINA_HOME/common && \\    ln -s /var/lib/tomcat8/server $CATALINA_HOME/server && \\    ln -s /var/lib/tomcat8/shared $CATALINA_HOME/shared && \\    ln -s /etc/tomcat8 $CATALINA_HOME/conf && \\    mkdir $CATALINA_HOME/temp

But the actual reason is probably in this question

CATALINA_BASE et al. only get set in /etc/init.d/tomcat8.
In the docker image, that service doesn't get initialized as it does in a full VM.