On this page

The properties of the Web Application Platform application are configured in the webappplatform.properties file. The sections below explain how these properties can be passed to a Docker container.

Copying properties to the classpath

By default, the webappplatform.properties file should be saved in the classpath. You can prepare the properties file and copy it to the classpath, as shown in bold in the example below:

Docker file example

FROM tomcat:9-jdk16-openjdk

ARG TOMCAT_HOME=/usr/local/tomcat

COPY logback.xml ${TOMCAT_HOME}/shared/conf/
COPY webappplatform.properties ${TOMCAT_HOME}/shared/conf/
COPY myapp.war ${TOMCAT_HOME}/webapps/

RUN sed -i "s|shared\.loader=*$|shared\.loader=\"\${catalina.base}/shared/conf\"|" ${TOMCAT_HOME}/conf/catalina.properties

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


Then one can use the following command to run the Docker container:

docker run -p 8080:8080 <image_name:version>


Passing Location of the Properties File as an ENV Parameter

You can also put the webappplatform.properties file in a location of your choice (not in the Tomcat classpath). This can be achieved if the path to the properties file is passed as the service.properties.file.location Java system property. The following sample script copies the webappplatform.properties file to the /srv/config/ location. The system property with such a location value is added to the setenv.sh file used by the Tomcat server. In the script, PROP_FILE_LOCATION_ENV is used as the environment variable and it needs to be passed when running the container.

Dockerfile example
FROM tomcat:9-jdk16-openjdk

ARG TOMCAT_HOME=/usr/local/tomcat
ARG SET_ENV_FILE=/usr/local/tomcat/bin/setenv.sh

COPY logback.xml ${TOMCAT_HOME}/shared/conf/
COPY myapp.war ${TOMCAT_HOME}/webapps/
COPY webappplatform.properties /srv/config/

RUN echo '#!/usr/bin/env bash' >> ${SET_ENV_FILE} RUN echo 'export JAVA_OPTS="$JAVA_OPTS –Dservice.properties.file.location=${PROP_FILE_LOCATION_ENV}"' >> ${SET_ENV_FILE}
RUN chmod o+x ${SET_ENV_FILE}

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


To pass the location value, the PROP_FILE_LOCATION_ENV environment variable value needs to be provided when running the container:

docker run -p 8080:8080 -e PROP_FILE_LOCATION_ENV='/srv/config/webappplatform.properties' <image_name:version>


Using a File from a Mounted Volume

If there are multiple Tomcat instances (e.g., due to multiple Docker containers), then you may want to store and maintain a single copy of the webappplatform.properties file. This can be achieved by keeping the file in the path that is external to the Docker container running an application. In such case, the properties file should be manually copied to the location of your choice leaving the Dockerfile with the following statements:

Dockerfile example

FROM tomcat:9-jdk16-openjdk

ARG TOMCAT_HOME=/usr/local/tomcat
ARG SET_ENV_FILE=/usr/local/tomcat/bin/setenv.sh

COPY logback.xml ${TOMCAT_HOME}/shared/conf/
COPY myapp.war ${TOMCAT_HOME}/webapps/

RUN echo '#!/usr/bin/env bash' >> ${SET_ENV_FILE} RUN echo 'export JAVA_OPTS="$JAVA_OPTS –Dservice.properties.file.location=${PROP_FILE_LOCATION_ENV}"' >> ${SET_ENV_FILE}
RUN chmod o+x ${SET_ENV_FILE}

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


When running a Docker image, the location must be mounted using the volume –v option. For more information, see https://docs.docker.com/get-started/06_bind_mounts/. Assuming that the properties file is stored in the /mnt/wap directory accessible to Docker containers, the following command will mount the path /mnt/wap to the /opt/wap of the Docker container:

docker run -p 8080:8080 --env PROP_FILE_LOCATION_ENV='/opt/wap/webappplatform.properties' –v /mnt/wap:/opt/wap <image_name:version>