Run XWiki (MariaDB on Tomcat) Using Docker Run

Last modified by Vincent Massol on 2026/07/27 16:43

Steps

To run XWiki with MariaDB using Docker Run:

  1. Create a dedicated Docker network.

    docker network create -d bridge xwiki-nw
  2. Create local directories for MariaDB data and initialization files.
    mkdir -p /my/path/mariadb
    mkdir -p /my/path/mariadb-init
  3. Create an initialization SQL file in /my/path/mariadb-init. Name it init.sql.
    grant all privileges on *.* to xwiki@'%';
  4. Start the MariaDB container. For example:
    docker run --net=xwiki-nw --name mariadb-xwiki \
    -v /my/path/mariadb:/var/lib/mysql \
    -v /my/path/mariadb-init:/docker-entrypoint-initdb.d \
    -e MYSQL_ROOT_PASSWORD=xwiki \
    -e MYSQL_USER=xwiki \
    -e MYSQL_PASSWORD=xwiki \
    -e MYSQL_DATABASE=xwiki \
    -d mariadb:12 \
    --character-set-server=utf8mb4 \
    --collation-server=utf8mb4_bin \
    --explicit-defaults-for-timestamp=1
  5. Create a local directory for the XWiki permanent directory.

    mkdir -p /my/path/xwiki
  6. Start the XWiki container. For example:
    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=mariadb-xwiki \
    xwiki:stable-mariadb-tomcat
  7. Open XWiki in your browser at http://localhost:8080.
  8. Follow the Distribution Wizard to finish the installation.

Don't forget to replace xwiki-nw with the name of your Docker network, the values of the environment variables, and the database and XWiki image tags used in the example with the ones you want (Supported tags and respective Dockerfile links).

FAQ

Should I change the default passwords used in the examples?

Yes. Replace the example passwords with your own values, both for the database superuser and for the xwiki database user. If you change the xwiki password, make sure to also update the SQL GRANT statement in the initialization file.

Why does the terminal stay busy after starting XWiki?

The example docker run command for the XWiki container has no -d flag, unlike the one for the database container, so XWiki runs in the foreground and prints its log to the console. Press Ctrl+C to stop it. Add -d to run the container in detached mode instead, and follow the log with docker logs -f xwiki.

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.

Related

Get Connected