DHIS2 docker images : Issue with startup

Dear DHIS2 docker experts + @Gintare,

I was trying to use dhis2 docker images but facing the following issue (in several images) while generating the container,

Docker image >>>

SEVERE [main] org.apache.catalina.startup.HostConfig.beforeStart Unable to create directory for deployment: [/usr/local/tomcat/conf/Catalina/localhost]

I think the issue is related to the permission of the directory,
root@03c31ee8e036:/usr/local/tomcat# ls -la
total 200
drwxr-x— 1 root tomcat 4096 Mar 9 15:09 .
drwxr-xr-x 1 root root 4096 Oct 19 2019 …
-rw-r----- 1 root tomcat 18982 Oct 7 2019 BUILDING.txt
-rw-r----- 1 root tomcat 5408 Oct 7 2019 CONTRIBUTING.md
-rw-r----- 1 root tomcat 57092 Oct 7 2019 LICENSE
-rw-r----- 1 root tomcat 2333 Oct 7 2019 NOTICE
-rw-r----- 1 root tomcat 3255 Oct 7 2019 README.md
-rw-r----- 1 root tomcat 6849 Oct 7 2019 RELEASE-NOTES
-rw-r----- 1 root tomcat 16262 Oct 7 2019 RUNNING.txt
drwxr-x— 1 root tomcat 4096 Mar 9 15:09 bin
drwxr-x— 1 root tomcat 4096 Feb 18 13:20 conf
drwxr-x— 1 root tomcat 4096 Oct 19 2019 include
drwxr-x— 1 root tomcat 4096 Oct 19 2019 lib
drwxr-x— 1 tomcat tomcat 4096 Mar 9 15:10 logs
drwxr-x— 1 root tomcat 4096 Oct 19 2019 native-jni-lib
drwxr-x— 1 tomcat tomcat 4096 Oct 19 2019 temp
-rwxr-x— 1 root tomcat 3695 Mar 9 15:09 wait-for-it.sh
drwxr-x— 1 root tomcat 4096 Mar 9 15:10 webapps
drwxr-x— 1 tomcat tomcat 4096 Mar 9 15:10 work

I have tried changing the permission from the container and restart it (not regenerate) but the permission is reset back to the original when it is restarted. Is there any script which is running to set the directory permissions?

Alternatively, please suggest if i should check any other configurations.

Thank you in advance.

The entry point for the container runs Tomcat as the tomcat user: dhis2-core/docker-entrypoint.sh at master · dhis2/dhis2-core · GitHub ; so the conf folder needs to be writable for the tomcat user (either by changing the owner to tomcat, or adding w to the group permissions).

You could copy the linked docker-entrypoint.sh script to a new file, add a line above line 22 to either chown tomcat or chmod g+w as mentioned, and then docker run --entrypoint my-entrypoint.sh ... to add your own command(s) before tomcat starts. You can read more about overriding an image entrypoint at Docker run reference | Docker Documentation

2 Likes

Thank you so much for your suggestion. Will try this and inform the outcome.

Hey @Mohammad_Ullah ,

Does your container start up though? You should see that deployment was successful in the next log line like this:

11-Mar-2022 09:32:34.490 SEVERE [main] org.apache.catalina.startup.HostConfig.beforeStart Unable to create directory for deployment: [/usr/local/tomcat/conf/Catalina/localhost]
11-Mar-2022 09:32:34.498 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/tomcat/webapps/ROOT]

1 Like

That’s a good point @Gintare ; that directory is often created but then left empty on basic Tomcat deployments.

1 Like