导致的原因:由于docker hub仓库的一些tomcat版本问题。
1.后台运行并指定端口映射启动tomcat
命令:docker run --name mytomcat -d -p 8080:8080 tomcat:latest
2.查看防火墙状态
命令:service firewall status
3.关闭防火墙
命令:service firewalld stop
4.查看运行中的容器,并记录这个容器的 CONTAINER ID
命令:docker ps
5.如果这时候浏览器访问还是404的话,按以下方式处理。
命令:docker exec -it xxxxxx /bin/bash
说明:这个xxx是你启动Tomcat容器的 ID
6.查看内容
命令:ls -l
7.进入webapps目录,并列出内容。
命令:cd webapps
命令:ls -l
发现total 0 。 这个tomcat版本webapps目录下的内容为空的。访问当然404啦。都没index.jsp文件。
8.返回上一层目录
命令:cd …
9.命令1移除webapps目录,命令2把webapps.dist目录下的文件移动到webapps目录下。
命令1:rm -rf webapps
命令2:mv webapps.dist webapps
10.此时就可以正常访问啦…
docker启动tomcat成功,访问404
最新推荐文章于 2024-05-13 22:53:34 发布