BookStack with Docker Compose
BookStack is a simple, open-source, self-hosted, easy-to-use platform for organising and storing information. In the project's words: bookstackapp.com front page checked 2026-09-25
Add BookStack to the builder to use your own domain, get its passwords generated in your browser, and combine it with other apps in one file.
What BookStack needs
Only figures BookStack's own documentation publishes, each linked to the page it is on. Where the project gives no number, this page does not invent one.
| Resource | Minimum | Recommended |
|---|---|---|
| RAM | Not published by the project | |
| CPU | Not published by the project | |
| Disk | Not published by the project | |
docker-compose.yml
This is exactly what the builder writes for BookStack alone on example.org: the official definition with its published ports removed and Caddy added in front. The time zone is Etc/UTC here; the builder uses your browser's. Every ${VARIABLE} is defined in the .env below.
# docker-compose.yml built at dankhost.com for: BookStack
# Each app block is its official compose definition. Only the names were prefixed with
# the app slug (services, containers, volumes, bind folders, .env variables) so any set of
# apps can share one file; other differences are listed under "Changed:" in each block.
# Only Caddy publishes ports. Secrets live in .env next to this file.
services:
# ---- Caddy: the one reverse proxy, HTTPS certificates from Let's Encrypt ----
# Source: https://caddyserver.com/docs/running (checked 2026-09-23)
# Source: https://github.com/dani-garcia/vaultwarden/wiki/Using-Docker-Compose (checked 2026-09-23)
# Caddyfile goes in ./caddy/Caddyfile. Fixed address 172.30.0.2 so apps can trust it exactly.
caddy:
image: "caddy:2"
container_name: "caddy"
restart: "unless-stopped"
ports:
- "80:80"
- "443:443"
- "443:443/udp"
volumes:
- "./caddy:/etc/caddy"
- "caddy-data:/data"
- "caddy-config:/config"
networks:
proxy:
ipv4_address: "172.30.0.2"
# ---- BookStack (bookstack.example.org) ----
# Source: https://www.bookstackapp.com/docs/admin/installation/ (checked 2026-09-25)
# Source: https://codeberg.org/bookstack/devops/src/branch/main/config/lsio-docker/docker-compose.yml (checked 2026-09-25)
# Changed: Removed the '6875:80' port; Caddy reaches bookstack:80 on the proxy network. The documented container names bookstack and bookstack_mariadb become the builder's (bookstack, bookstack-mariadb).
# APP_URL is your https address instead of the example's localhost address on port 6875; the file says it must be the base URL you reach BookStack on in the browser.
# APP_KEY, the database password (used in both DB_PASSWORD and MYSQL_PASSWORD, which the file says must match) and the root password are generated instead of the example values. APP_KEY is 32 random letters and digits: Laravel takes a 32-character key as it is, and the 'base64:' prefix is only for a base64-encoded one.
# TZ is your time zone instead of Etc/UTC.
bookstack:
image: "lscr.io/linuxserver/bookstack:version-v26.03.3"
container_name: "bookstack"
environment:
PUID: "1000"
PGID: "1000"
TZ: "Etc/UTC"
APP_URL: "https://bookstack.example.org"
APP_KEY: "${BOOKSTACK_APP_KEY}"
DB_HOST: "mariadb"
DB_PORT: "3306"
DB_DATABASE: "bookstack"
DB_USERNAME: "bookstack"
DB_PASSWORD: "${BOOKSTACK_DB_PASSWORD}"
volumes:
- "./bookstack/bookstack_app_data:/config"
restart: "unless-stopped"
networks:
proxy: {}
bookstack-backend: {}
bookstack-mariadb:
image: "lscr.io/linuxserver/mariadb:11.4.9"
container_name: "bookstack-mariadb"
environment:
PUID: "1000"
PGID: "1000"
TZ: "Etc/UTC"
MYSQL_ROOT_PASSWORD: "${BOOKSTACK_DB_ROOT_PASSWORD}"
MYSQL_DATABASE: "bookstack"
MYSQL_USER: "bookstack"
MYSQL_PASSWORD: "${BOOKSTACK_DB_PASSWORD}"
volumes:
- "./bookstack/bookstack_db_data:/config"
restart: "unless-stopped"
networks:
bookstack-backend:
aliases:
- "mariadb"
networks:
# Pinned so the trusted-proxy address given to each app (172.30.0.2) is exact.
# If "docker compose up" reports "Pool overlaps", change 172.30.0 here, in Caddy's
# ipv4_address and in every trusted-proxy value to a free 172.x.0 range.
proxy:
ipam:
config:
- subnet: "172.30.0.0/24"
ip_range: "172.30.0.128/25"
gateway: "172.30.0.1"
bookstack-backend:
internal: true
volumes:
caddy-data:
caddy-config:
Caddyfile save as caddy/Caddyfile
Caddy gets and renews the HTTPS certificate for bookstack.example.org by itself once the DNS record points at your server and ports 80 and 443 reach it.
# Caddyfile built at dankhost.com. Save it as ./caddy/Caddyfile next to docker-compose.yml.
# Caddy gets and renews a Let's Encrypt certificate for each name below by itself,
# once the DNS records point at this server and ports 80 and 443 reach it.
# BookStack
bookstack.example.org {
reverse_proxy bookstack:80
}
.env
The secrets are left blank here on purpose: a password printed on a public page is the same for everyone who copies it. The builder fills them with random letters and digits made in your browser.
# .env for BookStack, from dankhost.com/app/bookstack/. Fill the blank secrets before starting. # Keep this file private (chmod 600). # BookStack # 32 random letters and digits: the builder fills this in your browser BOOKSTACK_APP_KEY= # 32 random letters and digits: the builder fills this in your browser BOOKSTACK_DB_PASSWORD= # 32 random letters and digits: the builder fills this in your browser BOOKSTACK_DB_ROOT_PASSWORD=
Changes from the official file
Besides prefixing every service, container, volume, folder and variable with bookstack (so any set of apps can share one file), these are all the differences from what the project documents:
- Removed the '6875:80' port; Caddy reaches bookstack:80 on the proxy network. The documented container names bookstack and bookstack_mariadb become the builder's (bookstack, bookstack-mariadb).
- APP_URL is your https address instead of the example's localhost address on port 6875; the file says it must be the base URL you reach BookStack on in the browser.
- APP_KEY, the database password (used in both DB_PASSWORD and MYSQL_PASSWORD, which the file says must match) and the root password are generated instead of the example values. APP_KEY is 32 random letters and digits: Laravel takes a 32-character key as it is, and the 'base64:' prefix is only for a base64-encoded one.
- TZ is your time zone instead of Etc/UTC.
Notes for BookStack behind the proxy
- BookStack's installation page lists this LinuxServer.io setup under community Docker containers: the images are maintained by LinuxServer.io, not by the BookStack project.
- Log in at https://bookstack.example.org with BookStack's default admin account, admin@admin.com / password, and change both at once.
- Update by changing the version in the image tag (version-v26.03.3) to the latest BookStack release, as the file's comment says.
How to run it
- At your DNS provider, add an A record named
bookstackon your domain pointing at the server's public IP address, and forward TCP 80, TCP 443 and UDP 443 to it. - Save the three files in one folder:
docker-compose.ymland.envside by side, the Caddyfile at./caddy/Caddyfile. Replaceexample.orgwith your domain in the Caddyfile, the compose file and the .env, or let the builder do it. - Fill the blank
BOOKSTACK_APP_KEY,BOOKSTACK_DB_PASSWORD,BOOKSTACK_DB_ROOT_PASSWORDin.env. The builder generates them; on the server,tr -dc A-Za-z0-9 </dev/urandom | head -c 32prints 32 random letters and digits. Thenchmod 600 .env. - Start it:
docker compose up -d docker compose logs -f caddy # watch the certificate arrive
- Open the new address (
bookstack.plus your domain) in a browser and follow the notes above.
Back it up
BookStack's backup page names two things: the database, saved with mysqldump, and the files (.env, public/uploads, storage/uploads, themes). In the LinuxServer.io image all of those live under /config, which is ./bookstack_app_data here.
Below is the BACKUP.md the builder writes next to the compose file above: which of its folders and volumes hold data, the dump command the project documents, rewritten for this file's service names, what to copy with which container stopped, and a restore check. Pick more apps in the builder and it covers them all in one file.
# BACKUP.md built at dankhost.com for: BookStack
What to copy from the docker-compose.yml built with this file, the database dump each project documents (rewritten for the service names in that file), what to copy with which container stopped, and how to check the result. Run every command in the folder that holds docker-compose.yml.
The folders are owned by the containers' users: put sudo in front of tar if it says "Permission denied". Named volumes live under /var/lib/docker/volumes, not next to the compose file, so they are copied through a throwaway ubuntu container (Docker's documented --volumes-from method). tar makes a full copy each run; for large folders an incremental tool (restic, borg, rsync) saves time and space.
Never run "docker compose down -v" on this file: it deletes the named volumes of every app in it.
## Before you start
BACKUP=/mnt/backup/selfhost # change this: a disk or machine other than this server's system disk
mkdir -p "$BACKUP"
## Every time: the three stack files
tar czf "$BACKUP/stack-files.tar.gz" docker-compose.yml .env caddy
.env holds the database passwords and secret keys the apps were set up with; keep this archive as private as the data.
## Caddy (the reverse proxy)
Caddy's docs: 'The data directory must not be treated as a cache.' It holds the TLS certificates and their private keys; without it Caddy has to ask Let's Encrypt for every certificate again.
- caddy-data (named volume, /data in caddy)
BACK UP: TLS certificates, private keys, OCSP staples.
- caddy-config (named volume, /config in caddy)
SKIP: the last active configuration, kept for 'caddy run --resume', which this setup does not use: it starts from the Caddyfile.
- ./caddy (/etc/caddy in caddy)
IN stack-files.tar.gz: the Caddyfile, copied with the stack files above.
Copy (Caddy keeps serving while you copy):
docker run --rm --volumes-from caddy -v "$BACKUP":/backup ubuntu tar cvf /backup/caddy-data.tar /data
Restore check:
tar tf "$BACKUP/caddy-data.tar" > /dev/null && echo OK
docker run --rm --volumes-from caddy -v "$BACKUP":/backup ubuntu bash -c "cd /data && tar xvf /backup/caddy-data.tar --strip 1"
Sources:
- Caddy docs: Conventions, Data directory: https://caddyserver.com/docs/conventions#data-directory (checked 2026-09-24)
- Docker docs: Volumes, Back up, restore, or migrate data volumes: https://docs.docker.com/engine/storage/volumes/#back-up-restore-or-migrate-data-volumes (checked 2026-09-24)
## BookStack
BookStack's backup page names two things: the database, saved with mysqldump, and the files (.env, public/uploads, storage/uploads, themes). In the LinuxServer.io image all of those live under /config, which is ./bookstack_app_data here.
What this compose mounts:
- ./bookstack/bookstack_app_data (/config in bookstack)
BACK UP: BookStack's /config: its .env (with APP_KEY), uploaded images, page attachments and themes.
- ./bookstack/bookstack_db_data (/config in bookstack-mariadb)
COVERED BY THE COMMAND BELOW: MariaDB data files; copy them only with the database stopped.
1. Stop bookstack. Stopping BookStack (not MariaDB) keeps page edits and uploads from arriving between the dump and the copy.
docker compose stop bookstack
2. Database dump for bookstack-mariadb:
docker compose exec -T bookstack-mariadb sh -c 'mariadb-dump -u "$MYSQL_USER" -p"$MYSQL_PASSWORD" "$MYSQL_DATABASE"' > "$BACKUP/bookstack.backup.sql"
The backup page gives mysqldump -u {mysql_user} -p {database_name} > bookstack.backup.sql. In the LinuxServer.io MariaDB image the tool is mariadb-dump, MariaDB's name for mysqldump; it runs inside the database container, which already has the user, password and database name in its environment.
3. Copy while bookstack is stopped:
tar czf "$BACKUP/bookstack-bookstack_app_data.tar.gz" ./bookstack/bookstack_app_data
4. Start it again:
docker compose start bookstack
Restore check:
grep -c 'Dump completed' "$BACKUP/bookstack.backup.sql" # 1 means mariadb-dump finished
tar tzf "$BACKUP/bookstack-bookstack_app_data.tar.gz" > /dev/null && echo OK
Put a copy back (with bookstack stopped):
tar xzf "$BACKUP/bookstack-bookstack_app_data.tar.gz" # recreates ./bookstack/bookstack_app_data; move the old folder aside first
The backup page restores the database with mysql -u {mysql_user} -p {database_name} < {backup_file_name}, then puts the files back. With this file's names:
docker compose up -d bookstack-mariadb
docker compose exec -T bookstack-mariadb sh -c 'mariadb -u "$MYSQL_USER" -p"$MYSQL_PASSWORD" "$MYSQL_DATABASE"' < "$BACKUP/bookstack.backup.sql"
docker compose up -d
Sources:
- BookStack docs: Backup and Restore (mysqldump; uploads, attachments, themes, .env): https://www.bookstackapp.com/docs/admin/backup-restore/ (checked 2026-09-25)
- MariaDB docs: mariadb-dump (formerly mysqldump): https://mariadb.com/docs/server/clients-and-utilities/backup-restore-and-import-clients/mariadb-dump (checked 2026-09-25)
- Docker docs: Volumes, Back up, restore, or migrate data volumes: https://docs.docker.com/engine/storage/volumes/#back-up-restore-or-migrate-data-volumes (checked 2026-09-25)
Sources
Every page below was fetched on the date shown.
- bookstackapp.com front page checked 2026-09-25 (what it does)
- BookStack docs: Installation (Docker: community LinuxServer.io setup and its example compose stack) checked 2026-09-25 (compose definition and proxy settings)
- BookStack devops repository: lsio-docker/docker-compose.yml (the example compose stack the docs link) checked 2026-09-25 (compose definition and proxy settings)
- Caddy docs: Keep Caddy running (Docker Compose section) checked 2026-09-23 (Caddy)
- Vaultwarden wiki: Caddy with HTTP challenge (uses the caddy:2 image) checked 2026-09-23 (Caddy)
- BookStack docs: Backup and Restore (mysqldump; uploads, attachments, themes, .env) checked 2026-09-25 (backup plan)
- MariaDB docs: mariadb-dump (formerly mysqldump) checked 2026-09-25 (backup plan)
- Docker docs: Volumes, Back up, restore, or migrate data volumes checked 2026-09-25 (backup plan)
- Caddy docs: Conventions, Data directory checked 2026-09-24 (backup plan)