docker安装Tomcat 404问题的解决方案
时间:2021-03-18 09:45:32|栏目:Tomcat|点击: 次
查找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页面了