Run XWiki with an External Solr Container

Last modified by Vincent Massol on 2026/07/27 15:33

Steps

This page adds a Solr container to an XWiki installation, so that XWiki uses it instead of the Solr instance embedded in XWiki. See External Solr for XWiki in Docker for what a remote Solr requires and how the image configures it. XWiki 17.10.11+, 18.4.3+, 18.6.0+ This procedure configures the remote Solr through the SOLR_BASE_URL environment variable, which earlier images do not have. The examples use MySQL, but the Solr part is identical with MariaDB and with PostgreSQL.

Using Docker Run

  1. Create a dedicated Docker network and start your database container, as described in Run XWiki (MySQL on Tomcat) Using Docker Run.
  2. Download the contrib/solr directory of the xwiki-docker repository, which holds the Dockerfile and the solr-init.sh script.
  3. Build the Solr image, passing the version of XWiki you run so that the matching cores are downloaded.
    docker build -t xwiki-solr --build-arg XWIKI_VERSION=18.5.0 /my/path/contrib/solr
  4. Create a local directory for the Solr index and give it to the Solr user and group of the image.
    mkdir -p /my/path/solr
    chown 8983:8983 /my/path/solr
  5. Start the Solr container.
    docker run --net=xwiki-nw --name solr-xwiki \
    -v /my/path/solr:/var/solr \
    -d xwiki-solr
  6. Create a local directory for the XWiki permanent directory.
    mkdir -p /my/path/xwiki
  7. Start the XWiki container, adding the SOLR_BASE_URL environment variable that points to the Solr container.
    docker run --init --net=xwiki-nw --name xwiki -p 8080:8080 \
    -v /my/path/xwiki:/usr/local/xwiki \
    -e DB_USER=xwiki \
    -e DB_PASSWORD=xwiki \
    -e DB_DATABASE=xwiki \
    -e DB_HOST=mysql-xwiki \
    -e SOLR_BASE_URL=http://solr-xwiki:8983/solr \
    xwiki:stable-mysql-tomcat
  8. Open XWiki in your browser at http://localhost:8080.
  9. Follow the Distribution Wizard to finish the installation.

Don't forget to replace xwiki-nw with the name of your Docker network, the /my/path/... directories and the values of the environment variables with your own, and 18.5.0 with the XWiki version behind the xwiki:stable-mysql-tomcat tag you use.

Using Docker Compose

  1. Set up the working directory and the configuration files for your database, as described in Run XWiki (MySQL on Tomcat) Using Docker Compose.
  2. Copy the contrib/solr directory of the xwiki-docker repository next to docker-compose.yml, under the name solr.
  3. Add an index service to docker-compose.yml, which builds that directory.
      index:
        build:
          context: ./solr
          args:
            XWIKI_VERSION: ${XWIKI_VERSION}
        container_name: xwiki-solr
        volumes:
          - solr-data:/var/solr
        networks:
          - bridge
  4. Add index to the depends_on list of the web service, and the base URL of the Solr container to its environment list.
          - SOLR_BASE_URL=http://xwiki-solr:8983/solr
  5. Declare the solr-data volume next to the volumes already listed at the end of the file.
      solr-data: {}
  6. Start the containers with docker compose up -d.

The XWIKI_VERSION build argument reuses the variable that the .env file already defines for the XWiki image tag, so the Solr cores stay in sync with the version of XWiki that Docker Compose starts.

FAQ

Can I use a database other than MySQL?

Yes. The Solr container and the SOLR_BASE_URL variable are the same for MariaDB and for PostgreSQL; only the database container changes.

When is the remote Solr configuration written?

On the container's first start only: the entry point writes solr.type and solr.remote.baseURL into the xwiki.properties file of the permanent directory, and reuses that file on later starts. Changing SOLR_BASE_URL afterwards means editing that file.

How do I check that the cores were created?

Publish the Solr port (-p 8983:8983) and open the Solr administration UI: the four xwiki_* cores must be listed there.

Why do the examples run an init process?

XWiki starts a LibreOffice server to convert office documents, and that server leaves orphaned processes behind, for example when soffice.bin restarts. The JVM, which is the container's PID 1 by default, never reaps them, so they pile up as zombie processes for as long as the container runs. Running a small init process as PID 1 instead reaps them: pass --init to docker run, or set init: true on the service in a Compose or stack file. The docker-compose.yml files provided by the xwiki-docker repository already set it.

More

To find more about the current topic, you can search or use the table below and filter the columns to narrow your choices.

Related

Get Connected