Install BookStack by Docker

Page content

BookStack logo

BookStack is a simple, self-hosted, easy-to-use platform for organising and storing information and documentation. Here is a note of the installatin BookStack on a Debian bookworm/12.4 server via Docker.

1. Install Docker

(1) Set up Docker’s apt repository:

# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

# Add the repository to Apt sources:
echo \
  "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] \
  "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update

(2) Install the Docker packages.

sudo apt-get install docker-ce docker-ce-cli docker-buildx-plugin docker-compose-plugin


docker compose also installed here.

(3) Verify that the installation is successful by running the hello-world image:

$ sudo docker run hello-world

2. Linux post-installation steps for Docker Engine

2.1 Manage Docker as a non-root user

The Docker daemon binds to a Unix socket, not a TCP port. By default it’s the root user that owns the Unix socket, and other users can only access it using sudo. The Docker daemon always runs as the root user.

If you don’t want to preface the docker command with sudo, create a Unix group called docker and add users to it. When the Docker daemon starts, it creates a Unix socket accessible by members of the docker group. On some Linux distributions, the system automatically creates this group when installing Docker Engine using a package manager. In that case, there is no need for you to manually create the group.


The docker group grants root-level privileges to the user. For details on how this impacts security in your system, see Docker Daemon Attack Surface.

To create the docker group and add your user:

(1) Create the docker group.

$ sudo groupadd docker

(2) Add your user to the docker group.

$ sudo usermod -aG docker $USER

(3) Log out and log back in so that your group membership is re-evaluated.

If you’re running Linux in a virtual machine, it may be necessary to restart the virtual machine for changes to take effect.

You can also run the following command to activate the changes to groups:

$ newgrp docker

(4) Verify that you can run docker commands without sudo.

$ docker run hello-world

(5) If you initially ran Docker CLI commands using sudo before adding your user to the docker group, you may see the following error:

WARNING: Error loading config file: /home/user/.docker/config.json -
stat /home/user/.docker/config.json: permission denied

This error indicates that the permission settings for the ~/.docker/ directory are incorrect, due to having used the sudo command earlier.

To fix this problem, either remove the ~/.docker/ directory (it’s recreated automatically, but any custom settings are lost), or change its ownership and permissions using the following commands:

$ sudo chown "$USER":"$USER" /home/"$USER"/.docker -R
$ sudo chmod g+rwx "$HOME/.docker" -R

2.2 Configure Docker to start on boot with systemd

Many modern Linux distributions use systemd to manage which services start when the system boots. On Debian and Ubuntu, the Docker service starts on boot by default. To automatically start Docker and containerd on boot for other Linux distributions using systemd, run the following commands:

$ sudo systemctl enable docker.service
$ sudo systemctl enable containerd.service

To stop this behavior, use disable instead.

$ sudo systemctl disable docker.service
$ sudo systemctl disable containerd.service

3. Install Docker compose

Docker compose has been installed as a docker plugin in Section 1.

Check installed docker compose version:

$ docker compose version
Docker Compose version v2.21.0

4. Setup BookStack via docker compose

4.1 Create user bookstack

Create a new user bookstack with uid and gid are 2001 to mantian the BookStack service and store the database under its home directory.

$ sudo addgroup --gid 2001 bookstack
$ sudo adduser --uid 2001 --gid 2001 bookstack

Add user bookstack into the docker user group.

$ sudo usermod -aG docker bookstack

Switch to user bookstack:

$ sudo su bookstack

Then create a directory data to store BookStack data:

$ mkdir data

4.2 Create compose.yml file

Switch to the data directory first:

$ cd data

Let’s assume the server IP address is, create the compose file compose.yml as:

version: "2"
    container_name: bookstack
      - PUID=2001
      - PGID=2001
      - APP_URL=
      - DB_HOST=bookstack_db
      - DB_PORT=3306
      - DB_USER=bookstack
      - DB_PASS=<passwd>
      - DB_DATABASE=bookstackapp
      - ./bookstack_app_data:/config
      - 6875:80
    restart: unless-stopped
      - bookstack_db
    container_name: bookstack_db
      - PUID=2001
      - PGID=2001
      - MYSQL_ROOT_PASSWORD=<db_root_passwd>
      - TZ=Europe/London
      - MYSQL_DATABASE=bookstackapp
      - MYSQL_USER=bookstack
      - MYSQL_PASSWORD=<passwd>
      - ./bookstack_db_data:/config
    restart: unless-stopped


  • Remember to replace <passwd> and <db_root_passwd> with your own password string.
  • 2001 is the UID and GID for user bookstack.
  • Please read the linuxserver docker-bookstack document for more configuration parameters.

4.2 Download and run docker images

$ docker compose up -d

If there were no error, it would create 2 new directories:

$ tree data -L 2
├── bookstack_app_data
│   ├── backups
│   ├── keys
│   ├── log
│   ├── nginx
│   ├── php
│   └── www
├── bookstack_db_data
│   ├── custom.cnf
│   ├── databases
│   └── log
└── compose.yml

11 directories, 3 files

Access your BookStack web interface at:


The default administrative user account information:


  1. Install Docker Engine on Debian
  2. Linux post-installation steps for Docker Engine
  3. docker-bookstack
  4. How to Install Bookstack using Docker