一、查找Tomcat镜像
[root@staging ~]# docker search tomcat
二、拉取Tomcat镜像
[root@staging ~]# docker pull tomcat
三、运行Tomcat
# 在/root目录下创建tomcat目录用于存储tomcat数据信息
[root@staging ~]# mkdir ~/tomcat
[root@staging ~]# cd ~/tomcat
[root@staging tomcat]# docker run -id \
-p 8080:8080 \
-v $PWD:/usr/local/tomcat/webapps \
-v /usr/share/zoneinfo/Asia/Shanghai:/etc/localtime \
--name=tomcat \
tomcat
四、验证Tomcat容器
[root@staging tomcat]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4a97dbb79aac tomcat "catalina.sh run" 2 minutes ago Up 2 minutes 0.0.0.0:8080->8080/tcp, :::8080->8080/tcp tomcat
五、编写Tomcat的html文件
[root@staging tomcat]# mkdir test && cd test
[root@staging test]# echo "you are dashuaibi!" > test.html
六、测试访问