How do I copy server.xml into dockerized tomcat when build an image

I want to run tomcat with my customized server.xml

I modified access log prefix as access_log instead of localhost_access_log

So I wrote Dockerfile like this

FROM tomcat:8.5.47-jdk8-openjdk
COPY target/poi-middle-0.1-SNAPSHOT.war /usr/local/tomcat/webapps/
COPY server.xml /user/local/tomcat/conf/

But tomcat server.xml file won’t copied.

tomcat in docker container still has it’s origin server.xml

I checked out with this command.

docker exec -it poi-middle cat /usr/local/tomcat/conf/server.xml

What was my mistake?


I build an image successfully. here are some logs.

$ docker image build -t testtomcat .
Step 1/3 : FROM tomcat:8.5.47-jdk8-openjdk
8.5.47-jdk8-openjdk: Pulling from library/tomcat
Status: Downloaded newer image for tomcat:8.5.47-jdk8-openjdk
 ---> 882487b8be1d
Step 2/3 : COPY target/poi-middle-0.1-SNAPSHOT.war 
 ---> 705b2a1cc60d
Step 3/3 : COPY server.xml /user/local/tomcat/conf/
 ---> ae70499b65bf
Successfully built ae70499b65bf
Successfully tagged testtomcat:latest

And then, I ran docker component using above image.

$ docker run -d --name poi-middle  -p 8000:8000 testtomcat

$ docker exec -it poi-middle cat /usr/local/tomcat/conf/server.xml
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
           prefix="localhost_access_log" suffix=".txt"
           pattern="%h %l %u %t &quot;%r&quot; %s %b" />

Source: StackOverflow