docker安装Tomcat出现 404的解决方法?相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。
查找tomcat的containerID,进入tomacat目录:
[root@promote ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES b52c4a46a432 nginx "/docker-entrypoin..." 4 minutes ago Up 4 minutes 0.0.0.0:8081->80/tcp nginx-test 02ffbf387631 tomcat "catalina.sh run" 45 minutes ago Up 45 minutes 0.0.0.0:8080->8080/tcp mytomcat
查看webapps发现里面为空
[root@promote ~]# docker exec -it 02ffbf387631 /bin/bash root@02ffbf387631:/usr/local/tomcat# ls -l total 124 -rw-r--r--. 1 root root 18982 Sep 10 08:25 BUILDING.txt -rw-r--r--. 1 root root 5409 Sep 10 08:25 CONTRIBUTING.md -rw-r--r--. 1 root root 57092 Sep 10 08:25 LICENSE -rw-r--r--. 1 root root 2333 Sep 10 08:25 NOTICE -rw-r--r--. 1 root root 3257 Sep 10 08:25 README.md -rw-r--r--. 1 root root 6898 Sep 10 08:25 RELEASE-NOTES -rw-r--r--. 1 root root 16262 Sep 10 08:25 RUNNING.txt drwxr-xr-x. 2 root root 4096 Sep 15 22:33 bin drwxr-xr-x. 1 root root 22 Oct 10 01:45 conf drwxr-xr-x. 2 root root 4096 Sep 15 22:33 lib drwxrwxrwx. 1 root root 177 Oct 10 01:45 logs drwxr-xr-x. 2 root root 134 Sep 15 22:33 native-jni-lib drwxrwxrwx. 2 root root 30 Sep 15 22:33 temp drwxr-xr-x. 2 root root 6 Sep 15 22:33 webapps drwxr-xr-x. 7 root root 81 Sep 10 08:23 webapps.dist drwxrwxrwx. 2 root root 6 Sep 10 08:20 work root@02ffbf387631:/usr/local/tomcat# cd webapps root@02ffbf387631:/usr/local/tomcat/webapps# ls -l total 0
删除webapps,将webapps.dist修改名称为webapps
root@02ffbf387631:/usr/local/tomcat/webapps# cd .. root@02ffbf387631:/usr/local/tomcat# rm -rf webapps root@02ffbf387631:/usr/local/tomcat# mv webapps.dist webapps root@02ffbf387631:/usr/local/tomcat# cd webapps root@02ffbf387631:/usr/local/tomcat/webapps# ls -l total 8 drwxr-xr-x. 3 root root 4096 Sep 15 22:33 ROOT drwxr-xr-x. 15 root root 4096 Sep 15 22:33 docs drwxr-xr-x. 6 root root 83 Sep 15 22:33 examples drwxr-xr-x. 5 root root 87 Sep 15 22:33 host-manager drwxr-xr-x. 6 root root 114 Sep 15 22:33 manager
重新在浏览器中访问:
没有提交的话,在镜像重启后,又会报404错误,要commit一下
[root@promote ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES b52c4a46a432 nginx "/docker-entrypoin..." 43 minutes ago Up 42 minutes 0.0.0.0:8081->80/tcp nginx-test 02ffbf387631 tomcat "catalina.sh run" About an hour ago Up About an hour 0.0.0.0:8080->8080/tcp mytomcat [root@promote ~]# docker commit 02ffbf387631 mytomcat sha256:b2c4b37c92c5c26b1285756bf04365b8f5a42a86d519a767ea528cda1af9a81a
再次访问就不需要配置,直接访问tomcat页面了
看完上述内容,你们掌握docker安装Tomcat出现 404的解决方法的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注亿速云行业资讯频道,感谢各位的阅读!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。