Docker start Tomcat container access port display 404 problem solution

If you have turned off the firewall and there is still a 404 problem, then it is determined that there is nothing in the webapps folder of tomcat

  • Start tomcat
docker run -d -p 8080:8080 tomcat:latest
  • View the started container
docker ps

Insert picture description here

  • Access to port 8080 returns 404
    Insert picture description here
    Solution(Centos6.8)
  • Check firewall status, if open, close
service iptables status
service iptables stop
  • If the firewall is turned off but access to tomcat still fails, then use the following name to enter the tomcat directory
docker exec -it a5f02a3e6dde(启动的tomcat容器的容器id) /bin/bash
  • View all files in the current folder (ls command)
  • Enter the webapps folder, if it shows total 0, we need to copy the content in webapps.dist to the webapps folder
cd webapps
ls #你会发现这个目录为空 没有欢迎页面
cd ../
rm -rf webapps
cp -r webapps.dist webapps
  • Visit ip: host port (8080) to access successfully

Guess you like

Origin blog.csdn.net/weixin_44726976/article/details/108781668