简体   繁体   中英

Tomcat server.xml doesn't work when first time start with docker

FROM tomcat:8.5.27-jre8-alpine

ADD server.xml /usr/local/tomcat/conf/server.xml

ADD app.war /usr/local/tomcat/webapps/

CMD ["catalina.sh", "run"]

This is my Dockerfile. I expect my customized server.xml would work when first time start the docker container with "catalina.sh run", but not.

I have to stop the container and restart it, then tomcat reload server.xml and it works.

Does anyone met this before or know what's the problem here?

The change I expect to have in server.xml are below:

 <Host name="localhost"  appBase="webapps"
                  unpackWARs="true" autoDeploy="true" deployOnStartup="true">

                <!-- SingleSignOn valve, share authentication between web applications
                     Documentation at: /docs/config/valve.html -->
                <!--
                <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
                -->

                <!-- Access log processes all example.
                     Documentation at: /docs/config/valve.html
                     Note: The pattern used is equivalent to using pattern="common" -->
                <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" />
                <Context path="" docBase="myapp" reloadable="true"></Context>
            </Host>

Makes myapp to root path "/".

@Ben Did you solve this problem? I faced same issue. I tried to copy customized server.xml when build an image And then I checked out container file system. It has not changed.

您可以使用COPY server.xml /usr/local/tomcat/conf/server.xml而不是ADD server.xml /usr/local/tomcat/conf/server.xml

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM