Run XWiki (PostgreSQL on Tomcat) Using Docker Run
Steps
To run XWiki with PostgreSQL using Docker Run:
Create a dedicated Docker network.
docker network create -d bridge xwiki-nw- Create a local directory for PostgreSQL data.
mkdir -p /my/path/postgres - Start the PostgreSQL container. For example:
docker run --net=xwiki-nw --name postgres-xwiki \ -v /my/path/postgres:/var/lib/postgresql \ -e POSTGRES_USER=xwiki \ -e POSTGRES_PASSWORD=xwiki \ -e POSTGRES_DB=xwiki \ -e POSTGRES_INITDB_ARGS="--encoding=UTF8 --locale-provider=builtin --locale=C.UTF-8" \ -d postgres:18 Create a local directory for the XWiki permanent directory.
mkdir -p /my/path/xwiki- 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=postgres-xwiki \ xwiki:stable-postgres-tomcat - Open XWiki in your browser at
http://localhost:8080. - 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
Which PostgreSQL data path should I mount?
The required mount path depends on the PostgreSQL image version. For versions up to 17 use mount path: /var/lib/postgresql/data, for version 18 and later /var/lib/postgresql. Use the path that matches the PostgreSQL image tag you are using.
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.