Home > Net >  Tomcat on Docker can't be found
Tomcat on Docker can't be found

Time:11-12

I am trying to run Tomcat on Docker but even though my container is running, when I go to localhost I get a not found error as it is possible to see in the image below enter image description here

I used the command docker pull tomcat to get Tomcat and then in order to start my container I runned the command docker run -p 8080:8080 -dit tomcat.

Why isn't Tomcat being found when I access localhost:8080?

I edited the file tomcat-users.xml adding the following code

<role rolename="manager-gui"/>
  <role rolename="manager-script"/>
  <user username="admin" password="admin" roles="manager-gui,manager-script,admin"/>

and the file 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>

and server.xml to change to port 8888

<Connector port="8888" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />

but still giving the error

CodePudding user response:

That's exactly what should happen when the tomcat Docker image is used. See the "How to use this image." section of the Docker Hub page. In order to start the manager application that it sounds like you're looking for, some configuration is required.

  • Related