下载tomcat
//拉取tomcat
docker pull tomcat
//挂载容器
docker run --name tomcat -p 8080:8080 -v $PWD/test:/usr/local/tomcat/webapps/test -d tomcat
//查看tomcat容器里webapps文件是否为空如为空,便把webapps.dist文件移到webapps文件
mv webapps.dist/* webapps
//重启tomcat
docker restart tomcat
注:安全组端口记得开
效果:
![在这里插入图片描述](https://img-blog.csdnimg.cn/be2ba9788259407baf0cda9c57a62582.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBARGFla2Vy,size_20,color_FFFFFF,t_70,g_se,x_16)