Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SEVERE [main] org.apache.catalina.startup.HostConfig.beforeStart Unable to create directory for deployment: [/usr/local/tomcat/conf/Catalina/localhost] Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/myapp]] #316

Open
FueledBy-Pizza opened this issue Jun 28, 2024 · 1 comment

Comments

@FueledBy-Pizza
Copy link

When running a tomcat Docker image, this error appears, despite the container seems to go on with the execution:
SEVERE [main] org.apache.catalina.startup.HostConfig.beforeStart Unable to create directory for deployment: [/usr/local/tomcat/conf/Catalina/localhost] Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/myapp]]

Steps to reproduce:
Distributor ID: Ubuntu
Description: Ubuntu 20.04.5 LTS
Release: 20.04
Codename: focal

Docker version 20.10.23, build 7155243

With the Docker image:

FROM tomcat:10.1.25-jdk17

#RUN mkdir -p /usr/local/tomcat/conf/Catalina/localhost #Hardcoding this privilege will obviously solve the problem

ADD ./asapianpr/asapianpr.war /usr/local/tomcat/webapps/
ADD ./asapianpr/ROOT /usr/local/tomcat/webapps/ROOT
RUN chown -R 8877:8877 /usr/local/tomcat/webapps/
RUN chmod -R g+rwx /usr/local/tomcat/webapps/

RUN chown -R 8877:8877 /usr/local/tomcat/temp/
RUN chmod -R g+rwx /usr/local/tomcat/temp/

RUN chown -R 8877:8877 /usr/local/tomcat/work/
RUN chmod -R g+rwx /usr/local/tomcat/work/

RUN mkdir -p /usr/local/tomcat/config
ADD ./asapianpr/config/asapianpr.settings /usr/local/tomcat/config/
RUN chown -R 8877:8877 /usr/local/tomcat/config/
RUN chmod -R g+rwx /usr/local/tomcat/config/

ADD ./setenv.sh /usr/local/tomcat/bin
RUN chown -R 8877:8877 /usr/local/tomcat/bin/
RUN chmod -R g+rwx /usr/local/tomcat/bin/

ENV TZ="Europe/Rome"

RUN useradd -ms /bin/bash -u 8877 user

USER user

EXPOSE 8080

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

This seems to be a known old problem: #128 and #209 .

@yosifkit
Copy link
Member

As far as I understand tomcat, we wouldn't want the conf directory writeable by the running user, since that could be a security concern. So, creating the configuration directories that your app needs should be done in your Dockerfile.

Though I would guess that if you're not putting any configuration in there, then they are probably not relevant and createDirs could be disabled in the server.xml. 🤷

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants