Skip to content
Snippets Groups Projects
README.md 38.87 KiB

What is XWiki

XWiki is a free wiki software platform written in Java with a design emphasis on extensibility. XWiki is an enterprise wiki. It includes WYSIWYG editing, OpenDocument based document import/export, semantic annotations and tagging, and advanced permissions management.

As an application wiki, XWiki allows for the storing of structured data and the execution of server side script within the wiki interface. Scripting languages including Velocity, Groovy, Python, Ruby and PHP can be written directly into wiki pages using wiki macros. User-created data structures can be defined in wiki documents and instances of those structures can be attached to wiki documents, stored in a database, and queried using either Hibernate query language or XWiki's own query language.

XWiki.org's extension wiki is home to XWiki extensions ranging from code snippets which can be pasted into wiki pages to loadable core modules. Many of XWiki Enterprise's features are provided by extensions which are bundled with it.

logo

Table of contents

Introduction

The goal is to provide a production-ready XWiki system running in Docker. This is why:

  • The OS is based on Debian and not on some smaller-footprint distribution like Alpine
  • Several containers are used with Docker Compose: one for the DB and another for XWiki + Servlet container. This allows the ability to run them on different machines for example.

How to use this image

You should first install Docker on your machine.

Then there are several options:

  1. Pull the xwiki image from DockerHub.
  2. Get the sources of this project and build them.

Pulling an existing image

You need to run 2 containers:

  • One for the XWiki image
  • One for the database image to which XWiki connects to

Using docker run

Start by creating a dedicated docker network:

docker network create -d bridge xwiki-nw

Then run a container for the database and make sure it's configured to use an UTF8 encoding. The following databases are supported out of the box:

  • MySQL
  • MariaDB
  • PostgreSQL

Starting MySQL

We will bind mount two local directories to be used by the MySQL container:

  • one to be used at database initialization to set permissions (see below),
  • another to contain the data put by XWiki inside the MySQL database, so that when you stop and restart MySQL you don't find yourself without any data.

For example:

  • /my/path/mysql-init
  • /my/path/mysql

You need to make sure these directories exist, and then create a file under the /my/path/mysql-init directory (you can name it the way you want, for example init.sql), with the following content:

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

This will provide enough permissions for the xwiki user to create new schemas which is required to be able to create sub-wikis.

Note: Make sure the directories you are mounting into the container are fully-qualified, and aren't relative paths.

docker run --net=xwiki-nw --name mysql-xwiki -v /my/path/mysql:/var/lib/mysql -v /my/path/mysql-init:/docker-entrypoint-initdb.d -e MYSQL_ROOT_PASSWORD=xwiki -e MYSQL_USER=xwiki -e MYSQL_PASSWORD=xwiki -e MYSQL_DATABASE=xwiki -d mysql:8.2 --character-set-server=utf8mb4 --collation-server=utf8mb4_bin --explicit-defaults-for-timestamp=1

You should adapt the command line to use the passwords that you wish for the MySQL root password and for the xwiki user password (make sure to also change the GRANT command).

Notes:

  • The explicit-defaults-for-timestamp parameter was introduced in MySQL 5.6.6 and will thus work only for that version and beyond. If you are using an older MySQL version, please use the following instead:

    docker run --net=xwiki-nw --name mysql-xwiki -v /my/path/mysql:/var/lib/mysql -v /my/path/mysql-init:/docker-entrypoint-initdb.d -e MYSQL_ROOT_PASSWORD=xwiki -e MYSQL_USER=xwiki -e MYSQL_PASSWORD=xwiki -e MYSQL_DATABASE=xwiki -d mysql:8.2 --character-set-server=utf8mb4 --collation-server=utf8mb4_bin

Starting MariaDB

This is exactly similar to starting MySQL and you should thus follow exactly the same steps as for MySQL. The only thing to change is the docker image for MariaDB: instead of mysql:<tag>, use mariadb:<tag>. For example: mariadb:11.1.

Full command example:

docker run --net=xwiki-nw --name mysql-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:11.1 --character-set-server=utf8mb4 --collation-server=utf8mb4_bin --explicit-defaults-for-timestamp=1

Starting PostgreSQL

We will bind mount a local directory to be used by the PostgreSQL container to contain the data put by XWiki inside the database, so that when you stop and restart PostgreSQL you don't find yourself without any data. For example:

  • /my/path/postgres

You need to make sure this directory exists, before proceeding.

Note Make sure the directory you specify is specified with the fully-qualified path, not a relative path.

docker run --net=xwiki-nw --name postgres-xwiki -v /my/path/postgres:/var/lib/postgresql/data -e POSTGRES_ROOT_PASSWORD=xwiki -e POSTGRES_USER=xwiki -e POSTGRES_PASSWORD=xwiki -e POSTGRES_DB=xwiki -e POSTGRES_INITDB_ARGS="--encoding=UTF8" -d postgres:16

You should adapt the command line to use the passwords that you wish for the PostgreSQL root password and for the xwiki user password.

Starting XWiki

We will also bind mount a local directory for the XWiki permanent directory (contains application config and state), for example:

  • /my/path/xwiki

Note Make sure the directory you specify is specified with the fully-qualified path, not a relative path.

Ensure this directory exists, and then run XWiki in a container by issuing one of the following command.

For MySQL:

docker run --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 xwiki:stable-mysql-tomcat

For PostgreSQL:

docker run --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=postgres-xwiki xwiki:stable-postgres-tomcat

Be careful to use the same DB username, password and database names that you've used on the first command to start the DB container. Also, please don't forget to add a -e DB_HOST= environment variable with the name of the previously created DB container so that XWiki knows where its database is.

At this point, XWiki should start in interactive blocking mode, allowing you to see logs in the console. Should you wish to run it in "detached mode", just add a "-d" flag in the previous command.

docker run -d --net=xwiki-nw ...

Using docker-compose

Another solution is to use the Docker Compose files we provide.

Consent

On this website, we use the web analytics service Matomo to analyze and review the use of our website. Through the collected statistics, we can improve our offerings and make them more appealing for you. Here, you can decide whether to allow us to process your data and set corresponding cookies for these purposes, in addition to technically necessary cookies. Further information on data protection—especially regarding "cookies" and "Matomo"—can be found in our privacy policy. You can withdraw your consent at any time.