# Wiki.js with PostgreSQL

> Powerful and extensible open source wiki with modern interface.

- Category: Productivity & Collaboration
- Difficulty: beginner
- Components: wikijs, postgresql
- Tags: wiki, documentation, wikijs, knowledge-base, markdown
- Source: https://docker.recipes/productivity/wikijs-complete

## Overview

Wiki.js is a modern, lightweight, and powerful wiki engine built on Node.js that provides a clean, intuitive interface for creating and managing documentation. Originally created by Nicolas Giard, Wiki.js has become one of the most popular self-hosted wiki solutions, offering features like real-time collaboration, Git synchronization, advanced search capabilities, and support for multiple authentication providers. Unlike traditional wikis with dated interfaces, Wiki.js provides a contemporary editing experience with support for Markdown, visual editing, and extensible functionality through modules.

This deployment combines Wiki.js with PostgreSQL as the database backend, creating a robust two-service architecture. The wikijs container runs the main application on port 3000, while the dedicated db container provides PostgreSQL 15 Alpine for data persistence. The services communicate over a private Docker network, with Wiki.js configured to connect to PostgreSQL using environment variables for database credentials and connection details. Both containers use persistent volumes to ensure data survives container restarts and updates.

This configuration is ideal for organizations and individuals who need a reliable, feature-rich wiki solution with enterprise-grade database capabilities. PostgreSQL's advanced features like full-text search, JSON support, and ACID compliance make it an excellent choice for Wiki.js deployments that expect growth, complex content structures, or integration with existing PostgreSQL infrastructure. The combination provides excellent performance, data integrity, and scalability compared to lighter database options.

## Features

- Modern visual editor with live preview alongside traditional Markdown support
- Git synchronization for version control and backup of wiki content
- Advanced full-text search powered by PostgreSQL's search capabilities
- Multiple authentication providers including LDAP, OAuth, and SAML
- Page hierarchy and navigation with automatic breadcrumbs and tree structure
- Real-time collaborative editing with conflict resolution
- Asset management for images, documents, and media files
- Extensible module system for custom functionality and integrations

## Use cases

- Corporate knowledge bases and internal documentation for growing teams
- Technical documentation for software projects with Git workflow integration
- Educational institutions managing course materials and collaborative research
- Open source projects requiring professional documentation sites
- IT departments creating runbooks, procedures, and system documentation
- Startups building internal wikis that need to scale with company growth
- Personal knowledge management for researchers and content creators

## Prerequisites

- Docker and Docker Compose installed on the host system
- Minimum 1GB RAM available (512MB for Wiki.js, 512MB for PostgreSQL)
- Port 3000 available for Wiki.js web interface access
- Environment variable DB_PASSWORD configured for database authentication
- Basic understanding of wiki markup and Markdown syntax
- Approximately 2GB disk space for initial installation and content growth

## docker-compose.yml

```yaml
services:
  wikijs:
    image: ghcr.io/requarks/wiki:2
    container_name: wikijs
    environment:
      - DB_TYPE=postgres
      - DB_HOST=db
      - DB_PORT=5432
      - DB_USER=wiki
      - DB_PASS=${DB_PASSWORD}
      - DB_NAME=wiki
    volumes:
      - wikijs-data:/wiki/data
    ports:
      - "3000:3000"
    depends_on:
      - db
    networks:
      - wikijs-network
    restart: unless-stopped

  db:
    image: postgres:15-alpine
    container_name: wikijs-db
    environment:
      - POSTGRES_USER=wiki
      - POSTGRES_PASSWORD=${DB_PASSWORD}
      - POSTGRES_DB=wiki
    volumes:
      - postgres-data:/var/lib/postgresql/data
    networks:
      - wikijs-network
    restart: unless-stopped

volumes:
  wikijs-data:
  postgres-data:

networks:
  wikijs-network:
    driver: bridge
```

## .env

```bash
# Wiki.js
DB_PASSWORD=secure_wiki_password
```

## Usage notes

- Web UI at http://localhost:3000
- Complete setup wizard on first visit
- Supports Markdown, HTML, visual editor
- Git sync, search, and analytics
- Multiple auth providers supported

## Troubleshooting

- Wiki.js shows database connection error: Verify DB_PASSWORD environment variable matches between wikijs and db services
- Setup wizard not accessible at localhost:3000: Check that port 3000 is not blocked by firewall or used by another service
- PostgreSQL container fails to start with data directory error: Ensure postgres-data volume has proper permissions or remove volume to reset
- Wiki.js container restarts continuously: Check logs with 'docker logs wikijs' and verify all required environment variables are set
- Git sync fails during Wiki.js operation: Ensure Wiki.js container has network access and valid Git credentials configured in admin panel
- Search functionality not working properly: Restart wikijs container to rebuild search indices after PostgreSQL connection issues

