docker pull tomcat
tomcat版本
Server version: Apache Tomcat/9.0.36
Server built: Jun 3 2020 17:07:09 UTC
Server number: 9.0.36.0
OS Name: Linux
OS Version: 3.10.0-1062.9.1.el7.x86_64
Architecture: amd64
JVM Version: 11.0.7+10
JVM Vendor: Oracle Corporatio
所在目录
/usr/local/tomcat
创建本地的目录[root@VM_16_2_centos tomcat]# pwd
/root/tomcat
[root@VM_16_2_centos tomcat]# mkdir -p {webapps,logs}
[root@VM_16_2_centos tomcat]# ll
total 11
drwxr-xr-x 2 root root 4096 Jun 13 09:04 logs
drwxr-xr-x 2 root root 4096 Jun 13 09:04 webapps
[root@VM_16_2_centos tomcat]#
创建容器
docker run -d -p 8989:8080 --name tomcat -v ~/tomcat/logs:/usr/local/tomcat/logs -v ~/tomcat/webapps:/usr/local/tomcat/webapps tomcat tail -f /dev/null
进入容器启动tomcat
docker exec -it tomcat /bin/bash
cd bin
./startup.sh
然后退出容器 ctrl p + ctrl q
cd ~/tomcat/webapps
mkdir ROOT
cd ROOT
# 创建页面
echo "Hello Tomcat " > index.html
如图所示