What you will set up
BookStack is a wiki for a team's documentation: routines, server notes, how-tos, onboarding. Content is sorted like a library, into shelves, books, chapters and pages, and you write in an editor that works like a word processor, or in Markdown. It keeps every version of a page, searches all text, and has an audit log of who did what.
BookStack is created by Dan Brown, a developer in the United Kingdom, and developed with its community in the open on Codeberg, a code-hosting service run by a non-profit association in Berlin. It is open source under the MIT licence. Paid support is sold by HTTP Functions Ltd, a company registered in England. In the Podman tests it made no update check and sent no usage data. Out of the box it uses two outside services: it fetches a profile picture for every new user from Gravatar, run by Automattic in the United States, by sending a hash of the user's email address, and its diagram editor loads in the browser from diagrams.net, run by draw.io Limited in the United Kingdom. Step 3 switches both off.
BookStack publishes no container image of its own; its documentation points to two made by the community. This guide uses the one from LinuxServer.io, a group of volunteers who maintain a large set of container images. It is the first one BookStack's documentation lists, the release tested appeared there the next day, and it runs without root here. The other one is solidnerd/bookstack.
Here BookStack runs as two Compose services under a user of its own called bookstack, with MariaDB for its data, behind Caddy from the rootless Docker guide.
The Docker setup follows our tested rootless Docker guide on Debian 13. The app version and the app-specific behaviour below come from the tested Podman guide on a Melonslab server; the Docker steps for this app were not re-tested end to end. In the Podman test, the app used about 160 MB of memory, most of it MariaDB. The default admin was replaced before Caddy was set up, sign-ups and public access stayed off, the audit log showed each visitor's real address, and content, revisions, search and PDF export were checked. An update, a restore from backup and a reboot were also checked.
Before you start
You need:
- a server set up as in the rootless Docker guide, with Caddy running;
- an A record and an AAAA record for
wiki.example.compointing at your server.
The examples use wiki.example.com for the wiki and 203.0.113.10 for your server's IPv4 address, which ip -brief address show eth0 shows. Replace them throughout.
1. Create the user
As root:
useradd -m -s /bin/bash -U bookstack
loginctl enable-linger bookstack
mkdir -p /home/bookstack/bookstack/config /home/bookstack/bookstack/db
chown -R bookstack:bookstack /home/bookstack/bookstack
Do not add the user to the docker group. The daemon is rootless and belongs to this user.
2. Create the secrets
The application key comes from the BookStack image itself. Run it as bookstack:
uid=$(id -u bookstack)
runuser -u bookstack -- env HOME=/home/bookstack XDG_RUNTIME_DIR=/run/user/$uid \
DOCKER_HOST=unix:///run/user/$uid/docker.sock PATH=/usr/bin:/bin \
bash -lc "docker run --rm --entrypoint /bin/bash lscr.io/linuxserver/bookstack:latest appkey | tr -d '\\n' > /home/bookstack/bookstack/app-key"
The application key encrypts sessions and your users' two-factor secrets. Without it a restored backup is of little use, so step 11 saves a copy. As root, write both secrets to 0600 files:
umask 077
db_password=$(openssl rand -hex 24)
printf 'MARIADB_PASSWORD=%s\n' "$db_password" > /home/bookstack/bookstack/db.env
printf 'DB_PASSWORD=%s\n' "$db_password" > /home/bookstack/bookstack/secrets.env
printf 'APP_KEY=' >> /home/bookstack/bookstack/secrets.env
cat /home/bookstack/bookstack/app-key >> /home/bookstack/bookstack/secrets.env
printf '\n' >> /home/bookstack/bookstack/secrets.env
chown bookstack:bookstack /home/bookstack/bookstack/db.env /home/bookstack/bookstack/secrets.env
chmod 600 /home/bookstack/bookstack/db.env /home/bookstack/bookstack/secrets.env
Compose passes these files in as environment variables through env_file, so no secret appears in compose.yaml.
3. Define the Compose services
Create /home/bookstack/bookstack/compose.yaml:
cat > /home/bookstack/bookstack/compose.yaml <<'YAML'
services:
db:
image: docker.io/library/mariadb:11.8
env_file: db.env
environment:
MARIADB_DATABASE: bookstack
MARIADB_USER: bookstack
MARIADB_RANDOM_ROOT_PASSWORD: "1"
MARIADB_AUTO_UPGRADE: "1"
volumes:
- ./db:/var/lib/mysql
healthcheck:
test: ["CMD-SHELL", "healthcheck.sh --connect --innodb_initialized"]
interval: 10s
restart: always
app:
image: lscr.io/linuxserver/bookstack:latest
ports:
# Only Caddy, on this server, can reach BookStack: the port is not open to the internet.
- "127.0.0.1:8104:80"
env_file: secrets.env
environment:
APP_URL: "https://wiki.example.com"
APP_PROXIES: "203.0.113.10"
TZ: Europe/Stockholm
APP_DISPLAY_TIMEZONE: Europe/Stockholm
DISABLE_EXTERNAL_SERVICES: "true"
DB_HOST: db
DB_PORT: "3306"
DB_DATABASE: bookstack
DB_USERNAME: bookstack
volumes:
- ./config:/config
depends_on:
db:
condition: service_healthy
restart: always
YAML
What the settings do:
APP_URLis the address BookStack puts in every link and form. It must be the publichttps://address.APP_PROXIESis the address BookStack trusts to tell it the visitor's real address. Caddy's connections arrive from the server's own IPv4 address, as the rootless Docker guide explains, so that is the one to name. Without it, the audit log shows203.0.113.10for everyone.APP_DISPLAY_TIMEZONEshows times in Swedish time. BookStack still stores them in UTC, which is its default and keeps them right across daylight saving changes.TZsets the time zone of the container's own logs.DISABLE_EXTERNAL_SERVICES=truestops the Gravatar lookups and removes the draw.io diagram editor. Step 10 has the details.- MariaDB stays on 11.8, a long-term release, and
MARIADB_AUTO_UPGRADEupdates its system tables after an update within it. BookStack follows its releases, and updates its database by itself when it starts. - The uploaded images and files, and the container's web server settings, go in the
configdirectory; the pages themselves are in the database.
Start it:
uid=$(id -u bookstack)
runuser -u bookstack -- env HOME=/home/bookstack XDG_RUNTIME_DIR=/run/user/$uid \
DOCKER_HOST=unix:///run/user/$uid/docker.sock PATH=/usr/bin:/bin \
bash -lc "cd /home/bookstack/bookstack && docker compose pull && docker compose up -d"
The first start downloads about 780 MB of images, and BookStack takes a minute to set up its database. It is ready when this prints 302:
uid=$(id -u bookstack)
runuser -u bookstack -- env HOME=/home/bookstack XDG_RUNTIME_DIR=/run/user/$uid \
DOCKER_HOST=unix:///run/user/$uid/docker.sock PATH=/usr/bin:/bin \
bash -lc "curl -s -o /dev/null -w '%{http_code}\n' http://127.0.0.1:8104/"
Add the weekly docker-update.service and docker-update.timer from the rootless Docker guide, with WorkingDirectory=/home/bookstack/bookstack, and enable the timer as bookstack. Note the warning in step 12 about unattended updates of the LinuxServer.io image.
4. Replace the default admin
BookStack creates its first account as admin@admin.com with the password password, and anyone who knows that could log in as soon as the wiki is online. Change it before you add the wiki to Caddy. An SSH tunnel does not help here: BookStack sends every link and form to https://wiki.example.com, which does not answer yet. Use BookStack's own command instead:
uid=$(id -u bookstack)
runuser -u bookstack -- env HOME=/home/bookstack XDG_RUNTIME_DIR=/run/user/$uid \
DOCKER_HOST=unix:///run/user/$uid/docker.sock PATH=/usr/bin:/bin \
bash -lc "cd /home/bookstack/bookstack && docker compose exec -T app php /app/www/artisan bookstack:create-admin --initial --email=you@example.com --name='Your Name' --generate-password"
--initial replaces the details of the first admin account, instead of adding another one. The command prints a new random password and nothing else. Keep it in your password manager. You can change it later under My Account > Access & Security.
5. Put Caddy in front
As root, add this block at the end of /home/caddy/Caddyfile:
wiki.example.com {
reverse_proxy 127.0.0.1:8104
}
chown caddy:caddy /home/caddy/Caddyfile
uid=$(id -u caddy)
runuser -u caddy -- env HOME=/home/caddy XDG_RUNTIME_DIR=/run/user/$uid \
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$uid/bus PATH=/usr/bin:/bin \
bash -lc "export DOCKER_HOST=unix:///run/user/$uid/docker.sock; cd /home/caddy/caddy && docker compose restart caddy"
Open https://wiki.example.com. Log in with your email address and the password from step 4. The old login, admin@admin.com with password, gets "These credentials do not match our records."
6. Check who can get in
Under Settings:
- Registration: Enable registration is off, so nobody can sign up.
https://wiki.example.com/registertakes visitors back to the login page. - Features & Security: Allow public access is off, so every page needs a login.
You create accounts yourself under Settings > Users > Add New User. Until email works (step 9), switch off Send user invite email and set a password for the user.
On a new install of BookStack 26.09.1, the Editor role has no permissions for comments or attachments, so editors cannot comment on pages. Under Settings > Roles, open Editor. Under Asset Permissions, tick Create for Attachments and Comments, and Own under Edit and Delete for both, then Save Role. In the Podman test, the editor could comment afterwards.
Uploaded images are the exception to the login: a visitor who has an image's exact address can open it without logging in. BookStack does this for speed, and says so next to Enable higher security image uploads under Features & Security, which adds a random string to the names of new uploads. Keep that in mind before you upload screenshots that show passwords or customer data.
BookStack can also leave logins to a single sign-on service, such as authentik, over OpenID Connect or SAML 2.0, or to LDAP. That is set with AUTH_METHOD and the related settings in BookStack's documentation. We did not test it here. If the sign-in service runs on this same server, BookStack must be able to reach it from its Compose network, as described in the rootless Docker guide.
7. Shelves, books and pages
Content is organised in four levels: shelves hold books, books hold chapters and pages. To start:
- Books > Create New Book, give it a name, such as
Servers, and Save Book. - Shelves > New Shelf, give it a name, such as
IT, add the book with the + next to it under Add books to this shelf, and Save Shelf. - Open the book and choose New Page. The editor saves drafts as you type.
In the editor, Insert image opens the image manager, where Upload Image adds a picture from your computer; select it and choose Select Image to put it in the page. The More button at the end of the toolbar has Insert code block, which opens a code editor with a list of languages. Save Page publishes the page.
Each save is a new revision. Set Changelog next to Save Page adds a note to it, and Revisions on the page lists every version, with Changes to compare and Restore to go back. BookStack keeps the last 100 revisions of each page by default.
The search box at the top searches the text of every page, book and shelf you are allowed to see. Export on a page or a book gives you a PDF, a web page, Markdown, plain text or a ZIP file. To write in Markdown instead, the menu next to Editing Draft in the editor has Switch to Markdown Editor.
8. Use BookStack in Swedish
BookStack comes translated into Swedish. Each user picks Svenska under My Account > Profile Details > Preferred Language, and you can set it when you create the user.
To make Swedish the default for everyone who has not picked a language, add this line under the app service's environment: in /home/bookstack/bookstack/compose.yaml, and recreate the service as bookstack:
APP_LANG: sv
9. Email
BookStack sends email for invites, password resets, email confirmation on sign-up, and notifications about pages users watch. This guide does not set up email, and without it:
- creating a user with Send user invite email on fails with "Could not create user since invite email failed to send";
- Forgot Password? on the login page shows "An unknown error occurred" for an address that has an account;
- Settings > Maintenance > Send a Test Email shows the error,
Connection could not be established with host "localhost:587".
Accounts and logins with a password keep working.
To send email, point BookStack at an SMTP server, such as the one from the mail server guide or your email provider's. As root, add the password to the 0600 secret file:
umask 077
printf 'MAIL_PASSWORD=%s\n' 'the-smtp-password' >> /home/bookstack/bookstack/secrets.env
Then add these lines under the app service's environment: in compose.yaml, with your own server, account and sender address:
MAIL_DRIVER: smtp
MAIL_HOST: mail.example.com
MAIL_PORT: "587"
MAIL_ENCRYPTION: tls
MAIL_USERNAME: wiki@example.com
MAIL_FROM: wiki@example.com
MAIL_FROM_NAME: Wiki
Recreate the app service as bookstack with docker compose up -d, and use Send a Test Email to check it. Port 587 with MAIL_ENCRYPTION=tls uses STARTTLS; for port 465, which uses TLS from the start, change the port. We did not test sending, since this server has no mail server.
10. Outside services
With DISABLE_EXTERNAL_SERVICES=true from step 3, the server makes no outside connections in normal use. In the Podman test we checked by capturing its DNS lookups and outgoing connections while BookStack started, while a page was exported and while users were created. Without that line, two things change:
- When a user is created, the server fetches a picture from
www.gravatar.com, sending an MD5 hash of the user's email address. In the capture, each new user caused a lookup ofwww.gravatar.comand a connection to it. - The page editor gets a diagram button, and when a user opens it, their browser loads the draw.io editor from
embed.diagrams.net.
To keep diagrams without diagrams.net, run the draw.io web app yourself and point BookStack at it, after DISABLE_EXTERNAL_SERVICES=true:
DRAWIO: "https://draw.example.com/?embed=1&proto=json&spin=1&configure=1"
The draw.io web app has its own image, docker.io/jgraph/drawio. We did not test that setup.
Links and embedded videos that users add to pages, such as from YouTube, load from those sites in the reader's browser, as on any web page. Webhooks, under Settings > Webhooks, call the addresses you give them. A webhook to another app on this same server needs that app to be reachable from BookStack's Compose network; see the rootless Docker guide.
11. Back up
As root, with BookStack running:
umask 077
mkdir -p /home/bookstack/backup
chown bookstack:bookstack /home/bookstack/backup
uid=$(id -u bookstack)
runuser -u bookstack -- env HOME=/home/bookstack XDG_RUNTIME_DIR=/run/user/$uid \
DOCKER_HOST=unix:///run/user/$uid/docker.sock PATH=/usr/bin:/bin \
bash -lc "cd /home/bookstack/bookstack && docker compose exec -T db sh -c 'mariadb-dump -ubookstack -p\"\$MARIADB_PASSWORD\" --single-transaction bookstack' > /home/bookstack/backup/bookstack-db.sql"
tar -czf /home/bookstack/backup/bookstack-config.tar.gz -C /home/bookstack/bookstack config
tar -czf /home/bookstack/backup/bookstack-secrets.tar.gz -C /home/bookstack/bookstack db.env secrets.env
That is what BookStack's own backup advice asks for: the database, the uploaded images and files, and the application key. The pages, users, revisions and settings are in the database, and the images and attachments in config. The dump runs while BookStack keeps working. Copy /home/bookstack/backup to another machine, for example with restic, and store it safely: it holds all your content and the application key.
To restore into an empty database:
uid=$(id -u bookstack)
runuser -u bookstack -- env HOME=/home/bookstack XDG_RUNTIME_DIR=/run/user/$uid \
DOCKER_HOST=unix:///run/user/$uid/docker.sock PATH=/usr/bin:/bin \
bash -lc "cd /home/bookstack/bookstack && docker compose down"
rm -rf /home/bookstack/bookstack/db /home/bookstack/bookstack/config
tar -xzf /home/bookstack/backup/bookstack-config.tar.gz -C /home/bookstack/bookstack
tar -xzf /home/bookstack/backup/bookstack-secrets.tar.gz -C /home/bookstack/bookstack
runuser -u bookstack -- env HOME=/home/bookstack XDG_RUNTIME_DIR=/run/user/$uid \
DOCKER_HOST=unix:///run/user/$uid/docker.sock PATH=/usr/bin:/bin \
bash -lc "cd /home/bookstack/bookstack && docker compose up -d db"
uid=$(id -u bookstack)
until runuser -u bookstack -- env HOME=/home/bookstack XDG_RUNTIME_DIR=/run/user/$uid \
DOCKER_HOST=unix:///run/user/$uid/docker.sock PATH=/usr/bin:/bin \
bash -lc "cd /home/bookstack/bookstack && docker compose exec -T db healthcheck.sh --connect --innodb_initialized"; do sleep 2; done
runuser -u bookstack -- env HOME=/home/bookstack XDG_RUNTIME_DIR=/run/user/$uid \
DOCKER_HOST=unix:///run/user/$uid/docker.sock PATH=/usr/bin:/bin \
bash -lc "cd /home/bookstack/bookstack && docker compose exec -T db sh -c 'mariadb -ubookstack -p\"\$MARIADB_PASSWORD\" bookstack' < /home/bookstack/backup/bookstack-db.sql"
runuser -u bookstack -- env HOME=/home/bookstack XDG_RUNTIME_DIR=/run/user/$uid \
DOCKER_HOST=unix:///run/user/$uid/docker.sock PATH=/usr/bin:/bin \
bash -lc "cd /home/bookstack/bookstack && docker compose up -d app"
Starting only the database avoids BookStack setting up an empty database while the backup loads into it. On a new server, restore db.env and secrets.env from the backup instead of generating new ones in step 2.
12. Update
The weekly timer from step 3 pulls new images of BookStack and MariaDB and recreates the services. BookStack updates its database when it starts. Every start logs everyone out, as the LinuxServer.io image empties BookStack's sessions when it starts, so users log in again after an update, a restart or a reboot. To update now:
uid=$(id -u bookstack)
runuser -u bookstack -- env HOME=/home/bookstack XDG_RUNTIME_DIR=/run/user/$uid \
DOCKER_HOST=unix:///run/user/$uid/docker.sock PATH=/usr/bin:/bin \
bash -lc "cd /home/bookstack/bookstack && docker compose pull && docker compose up -d"
LinuxServer.io say they do not support unattended updates. If you would rather update by hand, replace latest in compose.yaml with a version tag, such as v26.09.1-ls287 from the image's list of tags, disable the timer, and change the tag when you want to update. Either way, keep your backups current, and read the release notes on BookStack's blog before larger updates.
Troubleshooting
Every entry in the audit log has the server's own address. APP_PROXIES is missing or names the wrong address. It must be the address Caddy connects from, not 127.0.0.1. Check it in compose.yaml, then recreate the app service.
"Could not create user since invite email failed to send". Email is not set up. Switch off Send user invite email and set a password, or set up email as in step 9.
"An unknown error occurred" after Forgot Password?. The same cause: BookStack could not send the reset email. Settings > Maintenance > Send a Test Email shows the error.