Run XWiki (MariaDB on Tomcat) Using Docker Swarm
Last modified by Eleni Cojocariu on 2026/05/07 16:21
Steps
To run XWiki with MariaDB using Docker Swarm:
- Enable Docker Swarm mode.
docker swarm init - Create the required Docker secrets.
- Create a secret for the database username.
- For Unix systems:
echo ${MY_XWIKI_USER:-xwiki} | docker secret create xwiki-db-username - - For Windows systems:
echo $env:MY_XWIKI_USER | docker secret create xwiki-db-username -
- For Unix systems:
- Create a secret for the database password.
echo YourDBPassword | docker secret create xwiki-db-password - - Create a secret for the MariaDB root password.
echo YourRootPassword | docker secret create xwiki-db-root-password -
- Create a secret for the database username.
- Create a stack definition file named xwiki-stack.yaml.
version: '3.3' services: web: image: "xwiki:stable-mariadb-tomcat" ports: - "8080:8080" environment: - DB_USER_FILE=/run/secrets/xwiki-db-username - DB_PASSWORD_FILE=/run/secrets/xwiki-db-password - DB_DATABASE=xwiki - DB_HOST=db volumes: - xwiki-data:/usr/local/xwiki secrets: - xwiki-db-username - xwiki-db-password db: image: "mariadb:11.6" volumes: - mariadb-data:/var/lib/mysql environment: - MYSQL_ROOT_PASSWORD_FILE=/run/secrets/xwiki-db-root-password - MYSQL_USER_FILE=/run/secrets/xwiki-db-username - MYSQL_PASSWORD_FILE=/run/secrets/xwiki-db-password - MYSQL_DATABASE=xwiki command: - "--character-set-server=utf8mb4" - "--collation-server=utf8mb4_bin" - "--explicit-defaults-for-timestamp=1" secrets: - xwiki-db-username - xwiki-db-password - xwiki-db-root-password volumes: mariadb-data: xwiki-data: secrets: xwiki-db-username: external: true xwiki-db-password: external: true xwiki-db-root-password: external: true - Deploy the stack.
docker stack deploy -c xwiki-stack.yaml xwiki - Verify that the services are running.
docker service ls - Open XWiki in your browser at
http://localhost:8080. Both services should show 1/1 under REPLICAS. This may take a few minutes.
Don't forget to replace example values such as ${MY_XWIKI_USER:-xwiki}, $env:MY_XWIKI_USER, passwords, image tags, database names, and hostnames with values that match your environment.
FAQ
What if I want to generate a random password instead of choosing one?
You can create random passwords for xwiki-db-password, or for xwiki-db-root-password as it follows:
- On Unix systems:
echo $(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 16 | head -n 1) | docker secret create xwiki-db-password - - On Windows:
-join ((48..57) + (65..90) + (97..122) | Get-Random -Count 16 | % {[char]$_}) | docker secret create xwiki-db-root-password -
Why do my secrets fail (on Windows)?
Windows CMD's echo command adds a trailling space to the value, which can cause authentication errors. You may use PowerShell instead.