Thank you for being a valued client of CM First Group. If you have any technical issues or concerns, please open a ticket on, email CM First technical support at or call us on our 24/7 customer hotline at +1 (512) 623-7586.


How to Create and Run Apache Tomcat Docker Container


How to Create an Apache Tomcat Docker with a WAR File Uploaded

  1. Create a directory for the dockerfile with,, your WAR file, and customized web.xml.

    Most of the time the values in and are different in the development and deployment environment. To override the and files that are in the WAR file from the development environment, we will have a separate copy of each, and web.xml files for deployment environment copied into the docker container. 

    To override from the WAR file, you set the properties below in file.


    The environment data source in should match the MS SQL docker image name, for example:

    See how to externalize file.

  2. To automatically create a Tomcat web server docker with externalized and, as well as WAR file uploaded, you will need to create a dockerfile as follows. 

    # Pull base image 
    From tomcat:8-jre8 

    # Maintainer 
    MAINTAINER "youremailaddress" 

    # Copy to images tomcat path 
    ADD web.xml /usr/local/tomcat/conf/ 
    ADD /etc/ 
    ADD /etc/ 
    ADD yourwarfile.war /usr/local/tomcat/webapps/ 

    To set the username and password to access Tomcat admin page. You can add settings.xml and tomcat-users.xml to the container by adding the following code in the dockerfile after the MAINTAINER line.

    ADD settings.xml /usr/local/tomcat/conf/
    ADD tomcat-users.xml /usr/local/tomcat/conf/

  3. Build the docker file by navigating to the directory where your dockerfile is created.

    docker build --tag mywebserver .

  4.  How to run the image container.

    docker run -it --rm -p 8888:8080 mywebserver

    You can then go to http://localhost:8888 or http://host-ip:8888 in a browser.

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request


Powered by Zendesk