How to run Bookstack as Docker Container

Supported Architectures

We utilize the docker manifest for multi-platform awareness. More information is available from docker here and our announcement here.

Simply pulling lscr.io/linuxserver/bookstack:latest should retrieve the correct image for your arch, but you can also pull specific arch images via tags.

The architectures supported by this image are:

ArchitectureAvailableTag
x86-64amd64-<version tag>
arm64arm64v8-<version tag>
armhfarm32v7-<version tag>
Application Setup

The default username is [email protected] with the password of password, access the container at http://dockerhost:6875.

This application is dependent on a MySQL database be it one you already have or a new one. If you do not already have one, set up our MariaDB container here Docker .

If you intend to use this application behind a subfolder reverse proxy, such as our SWAG container or Traefik you will need to make sure that the APP_URL the environment variable is set to your external domain, or it will not work.

Documentation for BookStack can be found at Docs .

BookStack File & Directory Paths

This container ensures certain BookStack application files & folders, such as user file upload folders, are retained within the /config folder so that they are persistent & accessible when the /config container path is bound as a volume. There may be cases, when following the BookStack documentation, that you’ll need to know how these files and folders are used relative to a non-container BookStack installation.

Below is a mapping of the container /config paths to those relative within a BookStack install directory:

  • /config container path => BookStack relative path
  • /config/www/.env => .env
  • /config/www/laravel.log => storage/logs/laravel.log
  • /config/www/files/ => storage/uploads/files/
  • /config/www/images/ => storage/uploads/images/
  • /config/www/themes/ => themes/
  • /config/www/uploads/ => public/uploads/
Advanced Users (full control over the .env file)

If you wish to use the extra functionality of BookStack such as email, Memcache, LDAP and so on you will need to make your own .env file with guidance from the BookStack documentation.

When you create the container, do not set any arguments for any SQL settings. The container will copy an exemplary .env file to /config/www/.env on your host system for you to edit.

PDF Rendering

wkhtmltopdf is available to use as an alternative PDF rendering generator as described at PDF Rendering .

The path to wkhtmltopdf in this image to include in your .env file is /usr/bin/wkhtmltopdf.

Usage

Here are some example snippets to help you get started creating a container.

docker-compose.yml file

version: "2"
services:
  bookstack:
    image: lscr.io/linuxserver/bookstack
    container_name: bookstack
    environment:
      - PUID=1000
      - PGID=1000
      - APP_URL=
      - DB_HOST=bookstack_db
      - DB_PORT=3306
      - DB_USER=bookstack
      - DB_PASS=<yourdbpass>
      - DB_DATABASE=bookstackapp
    volumes:
      - /path/to/data:/config
    ports:
      - 6875:80
    restart: unless-stopped
    depends_on:
      - bookstack_db
  bookstack_db:
    image: lscr.io/linuxserver/mariadb
    container_name: bookstack_db
    environment:
      - PUID=1000
      - PGID=1000
      - MYSQL_ROOT_PASSWORD=<yourdbpass>
      - TZ=Europe/London
      - MYSQL_DATABASE=bookstackapp
      - MYSQL_USER=bookstack
      - MYSQL_PASSWORD=<yourdbpass>
    volumes:
      - /path/to/data:/config
    restart: unless-stopped

For CLI user

docker run -d \
  --name=Bookstack -h Bookstack \
  -e PUID=1000 \
  -e PGID=1000 \
  -e TZ=Asia/Kolkata \
  -e APP_URL= \
  -e DB_HOST=<yourdbhost> \
  -e DB_PORT=<yourdbport> \
  -e DB_USER=<yourdbuser> \
  -e DB_PASS=<yourdbpass> \
  -e DB_DATABASE=bookstackapp \
  -p 6875:80 \
  -v /path/to/data:/config \
  --restart unless-stopped \
  lscr.io/linuxserver/bookstack:latest

This needs an MYSQL database

To create a database for Bookstack, run the below query

create database bookstackapp character set utf8mb4 collate utf8mb4_bin;
create user 'bookstackapp'@'%' identified by 'Bookstackapp@123';
GRANT ALL PRIVILEGES ON bookstackapp.* TO 'bookstackapp'@'%';
FLUSH PRIVILEGES;
Parameters

Container images are configured using parameters passed at runtime (such as those above). These parameters are separated by a colon and indicate <external>:<internal> respectively. For example, -p 8080:80 would expose port 80 from inside the container to be accessible from the host’s IP on port 8080 outside the container.

ParameterFunction
-p 80will map the container’s port 80 to port 6875 on the host
-e PUID=1000for UserID – see below for an explanation
-e PGID=1000for GroupID – see below for an explanation
-e TZ=Etc/UTCspecify a timezone to use, see this list.
-e APP_URL=for specifying the IP: port or URL your application will be accessed on (ie. http://192.168.1.1:6875 or https://bookstack.mydomain.com
-e DB_HOST=<yourdbhost>for specifying the database host
-e DB_PORT=<yourdbport>for specifying the database port if not default 3306
-e DB_USER=<yourdbuser>for specifying the database user
-e DB_PASS=<yourdbpass>for specifying the database password (non-alphanumeric passwords must be properly escaped.)
-e DB_DATABASE=bookstackappfor specifying the database to be used
-v /configthis will store any uploaded data on the docker host
Environment variables from files (Docker secrets)

You can set any environment variable from a file by using a special prepend FILE__.

As an example:

-e FILE__PASSWORD=/run/secrets/mysecretpassword

Will set the environment variable PASSWORD based on the contents of the /run/secrets/mysecretpassword file.

Leave a Reply

Your email address will not be published. Required fields are marked *