Docker container featuring: CentOS 7 + Java 8 + Tomcat 8
Put your WAR projects under /opt/tomcat/webapps directory (or any other as long as you make certain to adjust the values accordingly) and run the following command
# Setting some variables (directories must exist)
_EXPOSED_PORT=80; # The local forwarded port
_TOMCAT_BASE_DIR=/opt/tomcat; # The tomcat's local root directory
_TOMCAT_WEBAPPS_DIR=webapps; # The tomcat's local webapps directory
_TOMCAT_LOGS_DIR=logs; # The tomcat's local log directory
# Creating the base directories if they do not exist -- they should by now if you have added a war project to the tomcat's webapps...
mkdir -p ${_TOMCAT_BASE_DIR}/${_TOMCAT_WEBAPPS_DIR} && mkdir -p ${_TOMCAT_BASE_DIR}/${_TOMCAT_LOGS_DIR}
# The docker run command
docker run \
-p ${_EXPOSED_PORT}:8080 \
-v ${_TOMCAT_BASE_DIR}/${_TOMCAT_WEBAPPS_DIR}:/opt/tomcat/webapps \
-v ${_TOMCAT_BASE_DIR}/${_TOMCAT_LOGS_DIR}:/opt/tomcat/logs \
-it --name c7-tomcat ladybird/c7-tomcat
Once you run it, you can start the container with docker start c7-tomcat in next time and log file will be under the /opt/tomcat/logs directory.
Also, if you got some error, you can remove the container with docker rm c7-tomcat. Your current container list will be show with docker ps -a.
For Mac users, you must share the directory /opt/tomcat/webapps and /opt/tomcat/logs on Docker > Preferences > File Sharing.
If you get errors building image, please check the latest version of Java and Tomcat and ajust accordingly.
| Software | Version | Note |
|---|---|---|
| CentOS | 7 | |
| Java | 8u151 | Java Release Note |
| Apache Tomcat | 8.5.24 | Tomcat Download Page |
Docker Official Image for Tomcat is also available.
Content type
Image
Digest
Size
306.5 MB
Last updated
over 8 years ago
docker pull ladybird/c7-tomcat