欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

docker安装Tomcat 404问题的解决方案

程序员文章站 2022-07-03 23:14:53
查找tomcat的containerid,进入tomacat目录:[root@promote ~]# docker ps container id image command crea...

查找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

  重新在浏览器中访问:

docker安装Tomcat 404问题的解决方案

没有提交的话,在镜像重启后,又会报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问题的解决方案的文章就介绍到这了,更多相关docker安装tomcat 404内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!