Tomcat7 not starting inside Ubuntu Docker container

initial situation

In Ubuntu (14.04 / 14.10) a, the following commands were executed:

apt-get update && apt-get install tomcat7 service tomcat7 start 

For one thing, I tried this in the VirtualBox and tomcat7 virtual machine, as expected:

 vagrant init hashicorp/precise32 vagrant up 

On the other hand, I tried this in a Docker container, as shown here:

 sudo docker run -it --name tomcattest ubuntu bash 

Problem

There, the tomcat7 command command issues the [fail] command. However, tomcat works, but / var / log / tomcat 7 / catalina.out says the following:

 Apr 16, 2015 5:52:40 PM org.apache.catalina.startup.ClassLoaderFactory validateFile WARNING: Problem with directory [/usr/share/tomcat7/common/classes], exists: [false], isDirectory: [false], canRead: [false] Apr 16, 2015 5:52:40 PM org.apache.catalina.startup.ClassLoaderFactory validateFile WARNING: Problem with directory [/usr/share/tomcat7/common], exists: [false], isDirectory: [false], canRead: [false] Apr 16, 2015 5:52:40 PM org.apache.catalina.startup.ClassLoaderFactory validateFile WARNING: Problem with directory [/usr/share/tomcat7/server/classes], exists: [false], isDirectory: [false], canRead: [false] Apr 16, 2015 5:52:40 PM org.apache.catalina.startup.ClassLoaderFactory validateFile WARNING: Problem with directory [/usr/share/tomcat7/server], exists: [false], isDirectory: [false], canRead: [false] Apr 16, 2015 5:52:40 PM org.apache.catalina.startup.ClassLoaderFactory validateFile WARNING: Problem with directory [/usr/share/tomcat7/shared/classes], exists: [false], isDirectory: [false], canRead: [false] Apr 16, 2015 5:52:40 PM org.apache.catalina.startup.ClassLoaderFactory validateFile WARNING: Problem with directory [/usr/share/tomcat7/shared], exists: [false], isDirectory: [false], canRead: [false] Apr 16, 2015 5:52:40 PM org.apache.coyote.AbstractProtocol init INFO: Initializing ProtocolHandler ["http-bio-8080"] Apr 16, 2015 5:52:40 PM org.apache.catalina.startup.Catalina load INFO: Initialization processed in 514 ms Apr 16, 2015 5:52:41 PM org.apache.catalina.core.StandardService startInternal INFO: Starting service Catalina Apr 16, 2015 5:52:41 PM org.apache.catalina.core.StandardEngine startInternal INFO: Starting Servlet Engine: Apache Tomcat/7.0.52 (Ubuntu) Apr 16, 2015 5:52:41 PM org.apache.catalina.startup.HostConfig deployDirectory INFO: Deploying web application directory /var/lib/tomcat7/webapps/ROOT Apr 16, 2015 5:52:42 PM org.apache.coyote.AbstractProtocol start INFO: Starting ProtocolHandler ["http-bio-8080"] Apr 16, 2015 5:52:42 PM org.apache.catalina.startup.Catalina start INFO: Server startup in 1150 ms 

explanation found

Can someone distinguish another behavior and tell me if tomcat7 can be installed in a simple way via apt-get inside the docker container without warning?

+5
source share
2 answers

Decision

To run the tomcat script, special privileges are required. Specifically, he should check all running processes to make sure that he is running. You can grant the following privilege to the Docker container to make the launch of the tomcat script successful:

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

An important option is -cap-add SYS_PTRACE, all other options may vary. There is (at least one) question discussing this issue in docker github:

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

subsequent problems

However, I did not find a way to set this privilege to build docker images. My ultimate goal is to run the docker build, which runs the Ansible boot book. The assembly simply does not work due to the launch of the service, which I can not get out of the textbook. I will conduct further research, but possible solutions are welcome.

+12
source

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

I have no idea why, but it seems that 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 the creation of the temp directory. This means the following command in the Docker file:

 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 real reason is probably in this question

CATALINA_BASE et al. just get the value in /etc/init.d/tomcat8 .
In the docker image, this service is not initialized in the same way as in a full virtual machine.

+1
source

All Articles