部署Tomcat
要求:在docker中部署tomcat,并通过外部机器访问tomcat部署的项目
步骤:
1.搜索tomcat镜像
docker search tomcat
2.拉取tomcat镜像
docker pull tomcat
3.创建容器,设置端口映射、目录映射
mkdir ~/tomcat
cd ~/tomcat
docker run -id –name=c_tomcat \
-p 8080:8080 \ 将宿主机的8080映射到容器的8080端口
-v $PWD:/user/local/tomcat/webapps \ 将主机中当前目录挂载到容器的webapps
tomcat
4.部署项目
在宿主机的tomcat目录下创建项目,例如:test/index.html
5.测试访问
访问宿主机的ip,加上项目地址http://ip:8080/test/index
原文链接:https://blog.csdn.net/pcxiaoke/article/details/130957665?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522171836884016800178552552%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=171836884016800178552552&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_ecpm_v1~times_rank-1-130957665-null-null.nonecase&utm_term=docker%E9%83%A8%E7%BD%B2