Home Posts Calibre Web - Setup with Docker (Compose) & Traefik

Calibre Web — Setup with Docker (Compose) & Traefik

Calendar Icon (date post was published) published on  28 Dec 2020
Calendar Icon with Refresh Icon (date post was updated) updated on  05 Jan 2022

Intro

Calibre is a well known e-book management software. Calibre-Web, on the other side, is a web application allowing to access a Calibre library over the Web. It allows you to organize your books (and audiobooks) online in a similar manner as in the classical Calibre. The most important features are multi user support, conversion of ebooks between different file formats and sending them directly to your Kindle via E-Mail (if you set up a Kindle E-Mail address). Additionally, meta data for books can be fetched from the web (Google Books).

This guide explains how to install and setup Calibre Web using Docker (i.e., Docker Compose) and Traefik as Proxy.

Docker Compose File

The following docker-compose.yml file defines the only required service calibre-web that contains the entire application.
Two volumes, respectively bind mounts, are used to bind two folders into the container:

  • ./config:/config: Directory containing the configuration of Calibre-Web.
  • ./calibre-library:/books: Directory containing the Calibre Library Apart from the volumes, you should adjust the PUID and PGID values (environment variables) according to the user and group id of the owner of the two directories bound into the containers. You can find them out with the following command: id <username>.

The labels are used to configure Traefik and they expect the certificate provider to be named letsencrypt and the entrypoints for http and https named http and https. Also, adjust the domain according to your needs. All request are redirected to the secure https entrypoint. The network in which Traefik is available is named traefik_proxy. For more details regarding the Traefik setup, you can check out my related post. This post also explains the “secureHeaders@file” middleware.
If you are familiar with Traefik, you can adjust the labels according to your needs, just make sure to use port 8083 to “entry” the container.

The DOCKER_MODS variable defines optional additional “extensions”, provided by the LinuxServer.io team. The specified linuxserver/calibre-web:calibre extension adds support for converting ebooks to Calibre-Web. If you don’t require this feature, you can also remove the variable to keep the size of the final container smaller.

version: "3"
services:
  calibre-web:
    image: ghcr.io/linuxserver/calibre-web
    container_name: calibre-web
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/Berlin
      - DOCKER_MODS=linuxserver/calibre-web:calibre
    volumes:
      - ./config:/config
      - ./calibre-library:/books
    restart: unless-stopped
    labels:
      - "traefik.enable=true"
      - "traefik.docker.network=traefik_proxy"
      # Http (Only redirect to HTTPS)
      - "traefik.http.routers.calibre-web.entrypoints=http"
      - "traefik.http.routers.calibre-web.rule=Host(`calibre.your-domain.com`)"
      - "traefik.http.middlewares.calibre-web-https-redirect.redirectscheme.scheme=https"
      - "traefik.http.routers.calibre-web.middlewares=calibre-web-https-redirect"
      # Https
      - "traefik.http.routers.calibre-web-secure.entrypoints=https"
      - "traefik.http.routers.calibre-web-secure.rule=Host(`calibre.your-domain.com`)"
      - "traefik.http.routers.calibre-web-secure.tls=true"
      - "traefik.http.routers.calibre-web-secure.tls.certresolver=letsencrypt"
      - "traefik.http.routers.calibre-web-secure.service=calibre-web"
      - "traefik.http.routers.calibre-web-secure.middlewares=secureHeaders@file"
      # Service
      - "traefik.http.services.calibre-web.loadbalancer.server.port=8083"
      - "traefik.http.services.calibre-web.loadbalancer.server.scheme=http"
    networks:
      - traefik_proxy
networks:
  traefik_proxy:
    external: true

Initial Installation / Setup

The internal /books directory of the container contains the Calibre Library. I did not test the setup without copying an already existent library to the folder, respectively into the bound folder on the host machine. However, you can try to do so and let me know if it worked ;)
Otherwise, copy your library (i.e., the metadata.db file and all other folders from the “Library Folder”) into the ./calibre-library folder of the Docker-Host.

After setting up and adjusting the docker-compose.yml file you can simply start the service with the following command. The first boot up may take some more time, as the extension for ebook converting needs to be downloaded and installed, and the container generally is set up.

sudo docker compose up -d
# check the logs
sudo docker compose logs -f
# the following lines indicate that the setup is completed
# [services.d] starting services
# [services.d] done.

When the container is up and running, you should be able to open Calibre-Web in the browser by navigating to your defined URL. At first, you're asked to define where the library is saved. Type in the respective value from the docker-compose.yml file, in this case /books. After that, you can login with the admin account and admin123 as password.

Settings

E-Mail Server Configuration

To be able to send ebooks to your Kindle via mail and to send password-reset-mails you should add an SMTP server/ account. To do so, navigate to Admin → Edit E-Mail Server Settings and type in your SMTP credentials. You can test sending mails from there, too; but you have to set your personal E-Mail address before either in your profile (if that works) or through the admin interface (see below).

Basic Configuration

Some other configuration hints:

  • E-Book Conversion: To enable e-book conversion, goto Admin → Basic Configuration → External Libraries and set the Path to Calibre E-Book Converter value to /usr/bin/ebook-convert.
  • E-Mail E-Books to the Kindle: This requires you a) to setup your SMTP account and b) to define your Kindle e-mail address in your profile. Remember to add the “From-Mail” of the SMTP account you use to the allowed mails for sending documents to your kindle (in your Amazon account).
  • E-Book Uploads: E-book uploads have to be enabled in Admin → Edit Basic Configuration → Feature Configuration → Enable Uploads and also granted to each user via Admin → <username> → Allow Uploads.

Custom User E-Mail

For some reason, I am not able to edit the email address for my (admin) user in the “profile” page. However, changing the mail through the Admin interface (Admin → Users → <Your User> → E-Mail Address).

Further Resources

Categories: