Docker tomcat edits configuration files via dockerfile

I created a dockerfile and docker-compose file as shown below, which is a suppost for creating a tomcat image inside my container and editing tomcat users so that I can access the gui manager.
These four files are in the same folder where I run the docker build command.

docker-compose.yml

version: '2'

services:
  tomcat:
    build: .
    container_name: development
    ports:
      - 8001:8080
    environment:
      - spring.profiles.active=development

Dockerfile

FROM tomcat
COPY tomcat-users.xml /usr/local/tomcat/conf/
COPY context.xml /usr/local/tomcat/webapps/manager/META-INF/
CMD ["catalina.sh","run"]

tomcat-users.xml

<?xml version='1.0' encoding='cp1252'?>
<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">
    <user username="manager" password="pass" roles="manager-gui,manager-script"/>
    <user username="admin" password="pass" roles="tomcat"/>
</tomcat-users>

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>  

when I run the docker-compose up command, it creates a container with the tomcat image fine, but the existing tomcat-users.xml and context.xml are not overwritten. Any idea what I am doing wrong to overwrite these two files?

+4
1

. , , , . , , USER Docker, root.
Dockerfile :

FROM tomcat
USER root
COPY tomcat-users.xml /usr/local/tomcat/conf/
COPY context.xml /usr/local/tomcat/webapps/manager/META-INF/
CMD ["catalina.sh","run"]
+2

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


All Articles