XWiki deploying twice when CONTEXT_PATH variable is set up

Hello,

I am having an issue when running xwiki in a container with the CONTEXT_PATH environment variable set up.

The error is pretty easily reproduced, too.

  1. Clone the xwiki-docker repo
  2. Go to 18.4/postgres-tomcat
  3. Edit docker-compose.yml and add the environment variable CONTEXT_PATH to any value (besides the empty string), for instance “wiki"
  4. run docker compose up

We get an error by infinispan telling “The ‘org.xwiki.infinispan’ JMX domain is already in use.”, most likely by another xwiki instance!

When going to localhost:8080, I get a 404 error, but on localhost:8080/wiki, the xwiki instance works correctly.

In the logs, we can see these two lines :

 04-Aug-2026 14:39:43.774 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/tomcat/webapps/wiki] has finished in [21,719] ms
 04-Aug-2026 14:39:43.774 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/tomcat/webapps/ROOT]

meaning that two xwiki apps are starting. To ensure that we indeed have two xwiki running, I ran :

docker exec -t <container> ls -R /usr/local/tomcat/webapps/ROOT

and

docker exec -t <container> ls -R /usr/local/tomcat/webapps/wiki

I got the same results.

Investigating a little deeper, I noticed that in the file docker-entrypoint.sh, in the beginning of the configuration function, there is the following code:

if [ "$CONTEXT_PATH" == "ROOT" ]; then
  xwiki_set_cfg 'xwiki.webapppath' ''
else
  mkdir -p -v /usr/local/tomcat/webapps/$CONTEXT_PATH
  cp -a --update=none /usr/local/tomcat/webapps/ROOT/.  /usr/local/tomcat/webapps/$CONTEXT_PATH/
fi

This code first appears on this commit, and before that, the action was to move the ROOT repository, not copy it. I suppose to fix this issue one would need to create another docker image with the entrypoint file modified as it is copied into the container by the Dockerfile, at build time.

If this behaviour is intended however, I would gladly like to know where I am doing things wrong and how I can fix this issue :smiley:

Thank you very much!

error.log (100.5 KB)

Thanks a lot for the very well-researched report — your analysis is exactly right, and this is a bug, not intended behaviour.

I’ve reproduced it and filed Loading..., with the fix in XDOCKER-427: XWiki is deployed twice when CONTEXT_PATH is set to something other than ROOT by vmassol · Pull Request #101 · xwiki/xwiki-docker · GitHub. As you found, nothing removes webapps/ROOT after it’s copied to the context directory, and Tomcat auto-deploys every directory under webapps/, so two XWiki webapps start in the same JVM and the second one dies on the org.xwiki.infinispan JMX domain. The fix removes ROOT after the copy (the copy itself has to stay, so that config files bind-mounted into the context directory survive).

This will be released soon, on all branches (16.10.x, 17.10.x, 18.4.x and 18.x). I’ll try to do that in the coming days.

In the meantime you don’t need to rebuild the image: the entrypoint lives at /usr/local/bin/docker-entrypoint.sh, so you can extract it, add rm -rf /usr/local/tomcat/webapps/ROOT right after the cp, and bind-mount your copy over it.

Thx