Setting Up Wiki.js with Docker Compose: A ‘Fast-Light-Simple’ Knowledge Management Solution

Docker tutorial - IT technology blog
Docker tutorial - IT technology blog

Deploy Wiki.js lightning-fast in 5 minutes

Instead of struggling with manual library installations on your server, Docker Compose allows you to set up a top-tier Wiki site with just a few lines of code. It’s the go-to choice for teams needing a professional documentation hub with great Markdown support without wasting an entire afternoon on manual configuration.

First, ensure you have Docker installed on your machine. We’ll start by creating the workspace:

mkdir wiki-js && cd wiki-js
touch docker-compose.yml

Paste the following configuration into your docker-compose.yml file:

version: "3" 
services:
  db:
    image: postgres:15-alpine
    environment:
      POSTGRES_DB: wiki
      POSTGRES_PASSWORD: wikijsrocks
      POSTGRES_USER: wikijs
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
    restart: unless-stopped
    volumes:
      - ./db-data:/var/lib/postgresql/data

  wiki:
    image: requarks/wiki:2
    depends_on:
      - db
    environment:
      DB_TYPE: postgres
      DB_HOST: db
      DB_PORT: 5432
      DB_USER: wikijs
      DB_PASS: wikijsrocks
      DB_NAME: wiki
    restart: unless-stopped
    ports:
      - "8080:3000"
    volumes:
      - ./wiki-storage:/wiki/storage

To activate the system, simply run a single command:

docker-compose up -d

Now, visit http://localhost:8080. The setup screen will appear immediately. The entire process from pulling images to running the web app usually takes less than 5 minutes on a basic VPS.

Decoding the System Architecture

Why use this configuration? Wiki.js isn’t just a simple web app. It requires a “brain” behind the scenes to manage thousands of documents and handle user permissions.

PostgreSQL: The Optimal Choice for Performance

Wiki.js supports various databases like MySQL or MariaDB. However, Postgres is the “perfect match” due to its stable handling of full-text search and JSON data. Using the Alpine version as shown in the code, the image size is only about 150MB, significantly saving server resources.

Inter-Container Connectivity

Notice the DB_HOST: db line? In the world of Docker Compose, the service name acts as the network address. You don’t need to remember messy IP addresses. Docker automatically routes requests from the Wiki app to the database container accurately.

During configuration, if you need to inspect long JSON log files, try using the JSON Formatter at toolcraft.app. This tool reformats data instantly, helping you spot syntax errors in seconds without needing heavy browser extensions.

Advanced Configuration and Data Security

Don’t let a month’s worth of documentation vanish because you forgot to mount volumes. In Docker, if you don’t map directories to the host machine, all data will be wiped clean when the container is deleted or updated.

Smart Volume Management

In the configuration above, I’ve separated two critical areas:

  • ./db-data: Where all articles and system configurations are stored.
  • ./wiki-storage: Storage for images, PDF files, and attachments.

Pro-tip from experience: Back up the db-data folder daily. You can use the pg_dump command to export a backup SQL file in case of server hardware failure.

Optimizing Resources for Low-Spec VPS

By default, Wiki.js consumes about 200-300MB of RAM at idle. If your team has 20-30 frequent users, limit the resources to prevent crashing other services on the same server:

    deploy:
      resources:
        limits:
          memory: 1G

Another “worth its weight in gold” feature is Git Storage. You can connect Wiki.js to GitHub. Every time you hit Save, Wiki.js automatically pushes a copy to the repository. This serves as a highly secure secondary backup layer.

Real-World Operational Experience

After several internal Wiki deployments, here are some key takeaways to keep your system running smoothly:

  1. Use a Reverse Proxy: Don’t expose port 8080 directly to the internet. Use Nginx or Traefik as a front-end layer. This makes SSL (HTTPS) setup easier and more professional.
  2. Prioritize the Markdown Editor: If your team consists mostly of developers, enforce Markdown usage. It allows clean copy-pasting of code from VS Code into the Wiki while maintaining formatting.
  3. Strict Permissions: Never grant Admin rights to everyone. Clearly define groups: Editor (writing) and Reader (view-only) to avoid accidental deletion of critical documents.

If you encounter an EACCES error when writing files on Linux, run the command: chown -R 1000:1000 ./wiki-storage. This is the most common permission error encountered by Docker beginners. Good luck building a top-notch knowledge base for your team!

Share: