docker部署、运行tomcat问题

1.docker tomcat拉取

image
image
进入dockerHub选取自己需要的tomcat版本。
docker拉取命令
docker pull tomcat:tag tag为选择的版本号

2.tomcat启动

docker run -d --name tomcat01 -p 8888:8080 tomcat:tag
参数解释
-d:后台方式启动
--name:为当前容器命名
-p:虚拟机与容器端口映射

查看容器是否启动成功

docker ps

3.访问端口

访问地址:虚拟机ip:tomcat端口号、

4.问题解决

image
1.先查看防火墙状态,如未关闭,请关闭
查看:service firewalld status
关闭: service firewalld stop
启动: service iptables start
重启: iptables restart
永久关闭: chkconfig iptables off
永久关闭的–启动: chkconfig iptables on
2.交互模式进入tomcat容器内部
docker exec -it tomcat01 /bin/bash
进入webapp目录,查看是否有文件
cd webapps
没有文件则
rm -f webapps
cp -r webapps.dist/. webapps

posted @ 2022-09-28 13:33  轩qaq  阅读(302)  评论(0编辑  收藏  举报