在 docker 中运行 tomcat 时,无法访问 tomcat 管理器或任何其他默认的 tomcat 应用程序 [英] Cannot access tomcat manager or any other default tomcat app when running tomcat in docker

查看:69
本文介绍了在 docker 中运行 tomcat 时,无法访问 tomcat 管理器或任何其他默认的 tomcat 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从主机访问 tomcat 管理器应用程序.端口发布成功,但是尝试访问tomcat管理器时出现404错误.

I am trying to access tomcat manager app from host. The port publishing is successfull but when trying to access tomcat manager I get 404 error.

这是用于启动 tomcat 的命令:

This is the command used to launch the tomcat :

docker container run -p 8010:8080 --name mytomcat tomcat:9.0

并尝试通过 url 访问它:

and trying to access it by url :

http://localhost:8010/manager

从日志我可以确认tomcat正在运行,我可以从主机系统访问它,但是在访问管理器应用程序时,收到404.

From the logs I can confirm that tomcat is running, and I can access it from host system, but when accessing the manager app, 404 is received.

推荐答案

事实证明,对于从 Tomcat 版本 7 开始的所有 tomcat 图像,所有默认的 tomcat 应用程序都已从 webapps 目录中删除.所有应用程序都已移至 /usr/local/tomcat/webapps.dist 目录,因此默认情况下不会启动它们.您可以在此处阅读相关内容.

It turns out that all default tomcat apps have been removed from the webapps directory for all tomcat images starting with Tomcat version 7. All apps have been moved to /usr/local/tomcat/webapps.dist directory so that they are not launched by default. You can read about it here.

如果您仍想访问这些默认应用,您可以将它们复制回 webapps 目录,如果您愿意:

If you still want to access those default apps you can copy them back to the webapps directory, if you wish:

FROM tomcat:9.0
RUN mv /usr/local/tomcat/webapps.dist/* /usr/local/tomcat/webapps/
CMD ["catalina.sh","run"]

或仅复制您想要的应用.此外,您还必须编辑 tomcat 配置文件,以免在访问这些应用程序时出现 403.

or copy only the apps that you want. Also you will have to edit tomcat configuration files to not get 403 when accessing those apps.

这篇关于在 docker 中运行 tomcat 时,无法访问 tomcat 管理器或任何其他默认的 tomcat 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆