查找tomcat的containerID,進(jìn)入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發(fā)現(xiàn)里面為空
[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修改名稱(chēng)為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
重新在瀏覽器中訪(fǎng)問(wèn):
沒(méi)有提交的話(huà),在鏡像重啟后,又會(huì)報(bào)404錯(cuò)誤,要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
再次訪(fǎng)問(wèn)就不需要配置,直接訪(fǎng)問(wèn)tomcat頁(yè)面了
到此這篇關(guān)于docker安裝Tomcat 404問(wèn)題的解決方案的文章就介紹到這了,更多相關(guān)docker安裝Tomcat 404內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!