docker 运行tomcat 出现404错误!

docker 运行tomcat 出现404错误!

Scroll Down

我目前拉取的是最新的tomcat:9.0.35;

然后使用命令 docker run -it -p 7777:8080 tomcat,最后发现网页出现404错误,上网查询一般给出的处理方式基本如下,治标不治本,所以有所改善,如有错误,请留言多多指教!

  • 这是一般解决方案:
(base) [root@qi ~]# docker container ls
CONTAINER ID        IMAGE               COMMAND             CREATED              STATUS              PORTS                    NAMES
c8a751e11592        tomcat              "catalina.sh run"   About a minute ago   Up About a minute   0.0.0.0:7777->8080/tcp   wizardly_tesla
(base) [root@qi ~]# docker exec -it c8a751e11592 /bin/bash
root@c8a751e11592:/usr/local/tomcat# ls
BUILDING.txt     NOTICE         RUNNING.txt  lib             temp          work
CONTRIBUTING.md  README.md      bin          logs            webapps
LICENSE          RELEASE-NOTES  conf         native-jni-lib  webapps.dist
root@c8a751e11592:/usr/local/tomcat# cd webapps
root@c8a751e11592:/usr/local/tomcat/webapps# ls
root@c8a751e11592:/usr/local/tomcat/webapps# cd ..
root@c8a751e11592:/usr/local/tomcat# ls
BUILDING.txt     NOTICE         RUNNING.txt  lib             temp          work
CONTRIBUTING.md  README.md      bin          logs            webapps
LICENSE          RELEASE-NOTES  conf         native-jni-lib  webapps.dist
root@c8a751e11592:/usr/local/tomcat# mv webapps webapps2    
root@c8a751e11592:/usr/local/tomcat# mv webapps.dist webapps
root@c8a751e11592:/usr/local/tomcat# ls
BUILDING.txt     NOTICE         RUNNING.txt  lib             temp      work
CONTRIBUTING.md  README.md      bin          logs            webapps
LICENSE          RELEASE-NOTES  conf         native-jni-lib  webapps2
root@c8a751e11592:/usr/local/tomcat# cd webapps
root@c8a751e11592:/usr/local/tomcat/webapps# ls
ROOT  docs  examples  host-manager  manager

  • 一点点改变!

采取commit指令,来更正为自己的image,以便能一改受益于终身。
先退出此容器,Ctrl+P+Q,如果此指令不行,试一试Ctrl+D.
然后使用 docker commit -m="要描述的信息" -a="作者" 容器ID 自定义名字:标签
这样就把有一点错误的tomcat取代了,以后运行直接运行直接创建的tomcat即可!