Configure PostgreSQL for XWiki in Docker

Last modified by Eleni Cojocariu on 2026/07/13 21:54

Steps

Warning

WIP

To configure PostgreSQL for XWiki using Docker:

  1. Install Docker.
  2. Start a PostgreSQL container configured for XWiki.
    docker run --name xwiki-postgres \
    -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" \
    -v postgres-data:/var/lib/postgresql/data \
    -p 5432:5432 \
    -d postgres:17

    Replace postgres:17 with a supported PostgreSQL version. Replace POSTGRES_PASSWORD with a strong password for production environments. The container automatically creates the xwiki database and user on first startup.

  3. Download the appropriate PostgreSQL JDBC driver.
  4. Copy the JDBC driver JAR into the XWiki web application's WEB-INF/lib directory, the container's common library directory, or TOMCAT_HOME/lib.
  5. Edit the WEB-INF/hibernate.cfg.xml file from the expanded XWiki WAR directory.
  6. Remove or disable the configuration sections related to other databases.
  7. Uncomment the PostgreSQL configuration section.
  8. Configure the PostgreSQL connection URL.
     <property name="connection.url">jdbc:postgresql://localhost:5432/xwiki</property>
  9. Save the configuration changes.
  10. Restart XWiki to apply the changes.

Don't forget to replace example values such as environment variables, image tags, etc with values that match your environment.

FAQ

Is there other method of getting the JDBC diriver?

You can also download the JDBC driver directly from the Maven Central Repository and copy the JAR into your container's common lib directory, or in the XWiki webapp (in WEB-INF/lib), or (in TOMCAT_HOME/lib).

Should I use Docker Compose for production?

For production setups, consider using Docker Compose to run XWiki and PostgreSQL together in Docker on a shared network. This avoids exposing the database port to the host and simplifies configuration.

How do I remove the container and its data?

Stop and remove the container, then remove the volume:

docker stop xwiki-postgres && docker rm xwiki-postgres
docker volume rm postgres-data

Related

Get Connected