Prerequisites:
- Docker
How to install Docker
- Apache Tomcat Docker Image
How to download Apache Tomcat Docker image.
docker pull tomcat
How to Create an Apache Tomcat Docker with a WAR File Uploaded
- Create a directory for the dockerfile with obclient.properties, WebClient.properties, your WAR file, and customized web.xml.
Most of the time the values in obclient.properties and WebClient.properties are different in the development and deployment environment. To override the obclient.properties and WebClient.properties files that are in the WAR file from the development environment, we will have a separate copy of each obclient.properties, WebClient.properties and web.xml files for deployment environment copied into the docker container.
To override obclient.properties from the WAR file, you set the properties below in WebClient.properties file.
webclient.plex.propertyfilename=/etc/obclient.properties
webclient.plex.environmentname=DefaultThe environment data source in obclient.properties should match the MS SQL docker image name, for example:
Environment.Default.DataSource=jdbc:sqlserver://mysqlserver:1433;databaseName=yourdatabasename - To automatically create a Tomcat web server docker with externalized obclient.properties and WebClient.properties, 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
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 web.xml /usr/local/tomcat/conf/
ADD obclient.properties /etc/
ADD WebClient.properties /etc/
ADD yourwarfile.war /usr/local/tomcat/webapps/ADD settings.xml /usr/local/tomcat/conf/
ADD tomcat-users.xml /usr/local/tomcat/conf/ - Build the docker file by navigating to the directory where your dockerfile is created.
docker build --tag mywebserver .
- 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.
Comments
0 comments
Article is closed for comments.