我试图在Docker上运行Tomcat,但是即使我的容器正在运行,当我去localhost时,我会得到一个未找到的错误,在下面的图像中可以看到

我使用命令docker pull tomcat获取Tomcat,然后为了启动容器,我运行了命令docker run -p 8080:8080 -dit tomcat。
为什么当我访问localhost:8080时没有找到Tomcat
我编辑了tomcat-users.xml文件,添加了以下代码
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<user username="admin" password="admin" roles="manager-gui,manager-script,admin"/>和文件context.xml
<Context antiResourceLocking="false" privileged="true" >
<!-- Default set of monitored resources. If one of these changes, the -->
<!-- web application will be reloaded. -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<WatchedResource>WEB-INF/tomcat-web.xml</WatchedResource>
<WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>
<!-- Uncomment this to disable session persistence across Tomcat restarts -->
<!--
<Manager pathname="" />
-->
<Manager sessionAttributeValueClassNameFilter="java\.lang\.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\.filters\.CsrfPreventionFilter\$LruCache(?:\$1)?|java\.util\.(?:Linked)?HashMap"/>
</Context>和server.xml更改为端口8888。
<Connector port="8888" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />但还是给出了错误
https://stackoverflow.com/questions/74396346
复制相似问题