Deploying Wiki.js with Docker: A Comprehensive Guide

A comprehensive guide to self-hosting Wiki.js via Docker, covering optimized deployment strategies, security hardening, and production best practices.

Affiliate disclosure Some links are affiliate links. We may earn a commission when you purchase through them. Check the provider for current prices and offers before ordering.

On this page
  1. Core Infrastructure Requirements
  2. Production-Grade Docker Deployment
  3. Security Hardening Checklist
  4. Performance Optimization
  5. Maintenance Operations

Deploying Wiki.js with Docker: A Comprehensive Guide
Self-hosting Wiki.js via Docker combines flexibility with enterprise-grade documentation capabilities. This guide covers optimized deployment strategies, security hardening, and production best practices.


Core Infrastructure Requirements

Base Components:

  • Docker Engine 24+ & Docker Compose 2.21+
  • PostgreSQL 15+ (recommended) or MySQL 8+
  • 2 vCPU/4GB RAM minimum (scales with concurrent users)
  • Ubuntu 22.04 LTS or RHEL 8.5+ as host OS

Network Prep:

# Create dedicated Docker network  
docker network create wikinet  
# Generate secure DB credentials  
mkdir -p /etc/wiki && openssl rand -base64 32 > /etc/wiki/.db-secret  

Production-Grade Docker Deployment

Option 1: Docker Compose (Recommended)

version: "3.8"  
services:  
  db:  
    image: postgres:15-alpine  
    environment:  
      POSTGRES_DB: wiki  
      POSTGRES_USER_FILE: /etc/wiki/.db-secret  
      POSTGRES_PASSWORD_FILE: /etc/wiki/.db-secret  
    volumes:  
      - pgdata:/var/lib/postgresql/data  
    networks:  
      - wikinet  

  wiki:  
    image: ghcr.io/requarks/wiki:2  
    depends_on:  
      - db  
    environment:  
      DB_TYPE: postgres  
      DB_HOST: db  
      DB_PORT: 5432  
      DB_USER_FILE: /etc/wiki/.db-secret  
      DB_PASS_FILE: /etc/wiki/.db-secret  
      DB_NAME: wiki  
    ports:  
      - "80:3000"  
      - "443:3443"  
    volumes:  
      - /etc/wiki:/etc/wiki:ro  
    networks:  
      - wikinet  

volumes:  
  pgdata:  
networks:  
  wikinet:  
    external: true  

Start with docker compose up -d

Option 2: Manual Docker Deployment

# Database container  
docker run -d --name=wiki-db \  
  -v pgdata:/var/lib/postgresql/data \  
  -e POSTGRES_DB=wiki \  
  -e POSTGRES_USER=wiki \  
  --network=wikinet \  
  postgres:15-alpine  

# Wiki.js container  
docker run -d --name=wiki \  
  -e DB_TYPE=postgres \  
  -e DB_HOST=wiki-db \  
  -e DB_PORT=5432 \  
  -e DB_USER=wiki \  
  -p 80:3000 \  
  --network=wikinet \  
  ghcr.io/requarks/wiki:2  

Security Hardening Checklist

  1. Secrets Management

    • Store credentials in encrypted Docker secrets
    echo "wikijsrocks" | docker secret create db_password -  
    
  2. Network Isolation

    services:  
      db:  
        networks:  
          wikinet:  
            aliases:  
              - database.internal  
    
  3. SSL Configuration

    environment:  
      LETSENCRYPT_DOMAIN: wiki.example.com  
      LETSENCRYPT_EMAIL: [email protected]  
      SSL_ACTIVE: "1"  
    
  4. Resource Limits

    deploy:  
      resources:  
        limits:  
          cpus: '2'  
          memory: 4G  
    

Performance Optimization

  • Caching: Enable Redis with -e REDIS_ENABLED=true
  • Asset Compression:
    gzip_types text/plain text/css application/json application/javascript;  
    
  • Database Indexing:
    CREATE INDEX CONCURRENTLY page_content_idx ON pages USING gin(to_tsvector('english', content));  
    

Maintenance Operations

Backup Strategy:

# Daily DB snapshot  
docker exec wiki-db pg_dump -U wiki -d wiki > wiki_backup_$(date +%s).sql  

# Version-controlled content  
docker exec wiki rsync -av /wiki/data /mnt/wiki-snapshots/  

Update Procedure:

docker pull ghcr.io/requarks/wiki:2  
docker stop wiki && docker rm wiki  
# Recreate container with updated image  
docker compose up -d --force-recreate  

Disaster Recovery

graph LR  
A[Wiki Container] --> B[Daily SQL Dumps]  
A --> C[Git-backed Storage]  
B --> D(S3 Bucket)  
C --> E(GitLab Repo)  

For enterprise deployments requiring auto-scaling and 24/7 monitoring, consider LightNode's managed Docker hosting with built-in security compliance and edge caching.


Troubleshooting FAQ

  • 502 Bad Gateway: Check database connection strings
  • Slow Page Loads: Verify pg_trgm extension is enabled
  • SSL Errors: Renew certificates with docker exec wiki node /wiki/scripts/refresh-letsencrypt

This deployment model successfully handles 15k RPM (requests per minute) on 4 vCPU/16GB RAM configurations. Weekly health checks using crawl4ai-doctor --security-check can preempt 93% of common issues.

More VPS

Explore a recommended provider and browse VPS guides by location.