Docker Tomcat user configuration not working

Update: cleaning and direct indication of the problem and solution.

Problem:

Docker-tomcat was installed and launched correctly, with the exception of the 403 Access error in the Manager application. It also seems that my docker tomcat cannot find my tomcat-users.xml configuration.

Decision

Thanks Farhad and Sanket for answers.

[files]:

Dockerfile

FROM tomcat:8.5.11 MAINTAINER Borgy Manotoy < borgymanotoy@ujeaze.com > # Update Apt and then install Nano editor (RUN can be removed) RUN apt-get update && apt-get install -y \ nano \ && mkdir -p /usr/local/tomcat/conf # Copy configurations (Tomcat users, Manager app) COPY tomcat-users.xml /usr/local/tomcat/conf/ COPY context.xml /usr/local/tomcat/webapps/manager/META-INF/ 

Tomcat user configuration (conf / tomcat-users.xml)

 <tomcat-users xmlns="http://tomcat.apache.org/xml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd" version="1.0"> <role rolename="manager-gui"/> <role rolename="manager-script"/> <user username="admin" password="password" roles="manager-gui,manager-script" /> </tomcat-users> 

Application Context (webapps / manager / META-INF / context.xml)

 <?xml version="1.0" encoding="UTF-8"?> <Context antiResourceLocking="false" privileged="true" > <!-- <Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" /> --> </Context> 

[STEPS AND TEAMS]:

  • Docker image for assembly

    docker build -t borgymanotoy / my-tomcat-docker.

  • Run the image (my-tomcat-docker and set the port to 8088)

    docker run --name my-tomcat-docker-container -p 8088: 8080 -it -d borgymanotoy / my-tomcat-docker

  • Go to bash container (to check files inside container via bash)

    docker exec -it biyahe-tomcat-docker-container bash

+5
source share
2 answers

First you need to open the application in the container so that you can connect to it from dockerhost / network.

 docker run -d -p 8000:8080 tomcat:8.5.11-jre8 

You need to modify 2 files in order to access the mangaer application from a remote host. (The browser on the Docker host is considered remote, only packets received in the loopback containers are considered local to tomcat)

  • /usr/local/tomcat/webapps/manager/META-INF/context.xml Pay attention to the comment section.

     <Context antiResourceLocking="false" privileged="true" > <!-- <Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" /> --> 

Check out the comment section.

  1. /usr/local/tomcat/conf/tomcat-users.xml , as you stated in the question.

     <tomcat-users xmlns="http://tomcat.apache.org/xml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd" version="1.0"> <role rolename="manager-gui"/> <role rolename="manager-script"/> <user username="admin" password="password" roles="manager-gui,manager-script" /> 

To make changes to the files in the container, you can try to create your own image, but I suggest using docker tones or linking mounts.

+3
source

Please indicate the port when you do docker run as (I believe mine/tomcat-version is your image name)

docker run -p 8000:8080 -it -d --name MyContainerName mine/tomcat-version

then enter the manager page using

 http://<ipaddress>:8000/manager/html 

To get the host IP in docker, you need to run docker-machine ip

Additional information: you can also get into the container using the command below,

docker exec -it MyContainerName bash if you want to check out different things like tomcat logs, conf files, etc.

+1
source

Source: https://habr.com/ru/post/1265221/


All Articles