Skip to main content

Install your own BookStack instance

'> ℹ️ This guide starts from the point where you already have a Linux server and Docker is installed. The “steps before that” will follow later — it’s really not hard (especially with AI help).


Overview: What’s being set up here?

In the end you’ll have:

  • BookStack (wiki/docs system)
  • MariaDB as the database
  • Caddy as a reverse proxy with automatic HTTPS (Let’s Encrypt) 🌐

Background: What is Caddy? 🌐

Caddy is a modern web server (similar to Nginx/Apache), written in Go, that embraces “security-by-default” and, above all, makes HTTPS extremely convenient.

Core idea: “A web server that just works” ✅

Key features ✨

  1. Automatic HTTPS (TLS)
    • Certificates are obtained and renewed automatically (typically via Let’s Encrypt).
  2. Simple configuration
    • Via an easy-to-read Caddyfile.
  3. Reverse proxy & load balancing
    • Ideal for forwarding requests to services (e.g., Docker containers).
  4. Good defaults
    • Many sensible security standards are enabled by default.
  5. Modular extensibility
    • If you have special requirements, Caddy can be extended.

Typical use cases 🧩

  • Hosting websites (static/dynamic)
  • Reverse proxy in front of an app (e.g., /api → backend)
  • TLS termination
  • Local dev setups with HTTPS

Step 1: Prepare directory & files 🧱

Create the directory:

  • /opt/bookstack

Create two files inside it:

  • docker-compose.yml
  • Caddyfile

✍️ Important: You’ll need to adjust a few values in a moment — you can clearly see where in the YAML.


Step 2: Configure Docker Compose (docker-compose.yml) 🐳

Paste the following content (and adjust it where necessary):

services:
  mariadb:
    image: lscr.io/linuxserver/mariadb:latest
    container_name: bookstack-mariadb
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/Berlin
      - MYSQL_ROOT_PASSWORD=PW_OF_MYSQL_ROOT
      - MYSQL_DATABASE=bookstack
      - MYSQL_USER=bookstack
      - MYSQL_PASSWORD=PW_OF_MYSQL_DB
    volumes:
      - ./mariadb:/config
    restart: unless-stopped

  bookstack:
    image: lscr.io/linuxserver/bookstack:latest
    container_name: bookstack
    depends_on:
      - mariadb
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/Berlin

      - APP_URL=https://wiki.fabula.vision
      # Where will BookStack be accessible? (Your URL)
      - APP_KEY=base64:...
      # To generate it, run: docker run -it --rm --entrypoint /bin/bash lscr.io/linuxserver/bookstack:latest appkey
      - APP_THEME=custom
      #'custom' makes it possible to use hacks; more on that here: https://www.bookstackapp.com/hacks/applying/

      - DB_HOST=mariadb
      - DB_PORT=3306
      - DB_DATABASE=bookstack
      - DB_USERNAME=bookstack
      - DB_PASSWORD=PW_OF_MYSQL_DB
      # (As above!)

      - APP_DEFAULT_DARK_MODE=true
      # (Personal preference)

    volumes:
      - ./bookstack:/config
    restart: unless-stopped

  caddy:
    image: caddy:latest
    container_name: caddy
    depends_on:
      - bookstack
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile:ro
      - ./caddy/data:/data
      - ./caddy/config:/config
    restart: unless-stopped