Required Files for Docker Compose

Last modified by Eleni Cojocariu on 2026/04/29 08:45

Reference

To run XWiki with Docker Compose, you need three configuration files that are downloaded locally before starting the setup. These files are retrieved using commands from the tutorials (e.g., Run XWiki (MySQL on Tomcat) Using Docker Compose, Run XWiki (MariaDB on Tomcat) Using Docker Compose, Run XWiki (PostgreSQL on Tomcat) Using Docker Compose) such as wget or curl , and Docker Compose uses them to configure and start the containers.

Configuration FileDesctiption
init.sqlThis file contains some SQL executed when the database starts for the first time.
docker-compose.ymlThis is the main configuration file that defines the services (XWiki and the database), their settings, and how they interact.
.envThis file contains default configuration values (such as the XWiki version or database settings).

For reference, here's a init.sql (for MySQL) example:

grant all privileges on *.* to xwiki@'%'

For reference, here's a docker-compose.yml (for MySQL) example:

version: '2'
networks:
  bridge:
    driver: bridge
services:
  # The container that runs XWiki in Tomcat, with the appropriate JDBC driver (for mysql).
  web:
  image: "xwiki:${XWIKI_VERSION}-mysql-tomcat"
    container_name: xwiki-mysql-tomcat-web
    depends_on:
      - db
    ports:
      - "8080:8080"
    # Default values defined in .env file.
    # The DB_USER/DB_PASSWORD/DB_DATABASE/DB_HOST variables are used in the hibernate.cfg.xml file.
    environment:
      - XWIKI_VERSION=${XWIKI_VERSION}
      - DB_USER=${DB_USER}
      - DB_PASSWORD=${DB_PASSWORD}
      - DB_DATABASE=${DB_DATABASE}
      - DB_HOST=xwiki-mysql-db
    # Provide a name instead of an auto-generated id for xwiki data (the permanent directory in included in it)
    # configured in the Dockerfile, to make it simpler to identify in 'docker volume ls'.
    volumes:
      - xwiki-data:/usr/local/xwiki
    networks:
      - bridge
  # The container that runs the database (mysql)
  db:
  image: "mysql:9"
    container_name: xwiki-mysql-db
    # - Provide a name instead of an auto-generated id for the mysql data, to make it simpler to identify in
    # 'docker volume ls'
    # - Provide a SQL script to be executed when the db image starts (to set permissions to create subwikis)
    volumes:
      - mysql-data:/var/lib/mysql
      - ./init.sql:/docker-entrypoint-initdb.d/init.sql

    # Configure the MySQL database and create a user with provided name/password.
    # See https://hub.docker.com/_/mysql/ for more details.
    # Default values defined in .env file.
    environment:
      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
      - MYSQL_USER=${DB_USER}
      - MYSQL_PASSWORD=${DB_PASSWORD}
      - MYSQL_DATABASE=${DB_DATABASE}

    # Pass arguments to configure the database
    command:
      - "--character-set-server=utf8mb4"
      - "--collation-server=utf8mb4_bin"
      - "--explicit-defaults-for-timestamp=1"
    networks:
      - bridge
volumes:
  mysql-data: {}
  xwiki-data: {}

For reference, here's a .env (for MySQL) example: 

# Default environment values
XWIKI_VERSION=17.10.4
DB_USER=xwiki
DB_PASSWORD=xwiki
DB_DATABASE=xwiki
MYSQL_ROOT_PASSWORD=xwiki

Related

Get Connected