How to Run the Calibre Server Docker Container Natively, and on a QNAP NAS

How to Run the Calibre Server Docker Container Natively, and on a QNAP NAS
Image courtesy of PhotoRoom. License.

I need a new way to keep control of my ever-growing, ever-sprawling, e-book collection. Local files and folders has got me to a stage where it’s getting kinda messy and difficult to manage. Calibre seems to be the only show in town for managing, converting and keeping track of all of your e-books. So I thought I’d give it a try.

First step is first; installing the desktop application on my computer using Chocolatey choco install calibre. I then ran the application which started the configuration wizard, but the first page stopped me.

Calibre Configuration Wizard reminding you that you can export from an old computer and import to a new one

Calibre Configuration Wizard reminding you that you can export from an old computer and import to a new one.

I’ve used Calibre in the past and I always thought it was a static set of folders and files. So this made me wonder why I’d need instructions moving between computers.

Do not put your calibre library on a networked drive.

Calibre recommends not storing the Calibre library and database on a network drive. As I have multiple computers and wanted to use a network share or Syncthing to keep the content, I’m going to have to rethink this. It does appear many people are successfully using it this way, but I will need to be conscious to the risk of database corruption.

Docker Container

When running server side applications these days, I prefer to use Docker under my QNAP NAS. This allows me to run Docker containers in a limited way through the GUI (some features are not available) or in a manual way from the command line.

Calibre Server has a Docker image. In fact there are two - one for server and one for web. Calibre Server is only available as 64-bit for x86 and ARM. So no installing this on a Raspberry Pi. The Calibre Web Docker image is available for 32-bit ARM and it provides “a clean interface for browsing, reading and downloading eBooks using an existing Calibre database”.

I’ll only be concentrating on the Calibre Server Docker container for this post.

Getting Ready For Docker

Things you will need to decide before you start to use the Docker image:

  1. What port will you use?

    By default, the Calibre Server Desktop app will listen on port 8080. This is a commonly used port, so you may want to change it to something else. The Calibre Content Server port is 8081, which is another commonly used port. For this post I’m going to use ports 48080 and 48081. So the parameters I will add will be -p 48080:8080 -p 48081:8081.

  2. Will you set a password for your Calibre server?

    There is no password set as default. I’d always recommend you set a password, and you do that by adding the PASSWORD environment variable for the Docker container. For this post I’m going to use password for demo purposes so the parameter I will add will be -e PASSWORD='password'

  3. What is your timezone?

    You can set your timezone that Calibre Server will use by providing the TZ environment variable. I am in Europe/London so the parameter I will use is -e TZ='Europe/London'.

  4. Where will you store the library?

    Add the location you want to store you Calibre database and library using the -v parameter to mount it in Docker as a volume mapping to /config inside the container. I will use host location /calibre-library to map to the /config location inside the container. So the parameter I will add will be -v /calibre:/config.

  5. Where are your books?

    The Docker container needs access to a folder where you have, or will have, your books. This is going to be somewhere you can drop new books and then use the Calibre Server Desktop App to add to your library. Like the above Calibre library location, you will mount this as a volume using -v. There is no set mapping inside the Docker container to use, so I am going to use /mybooks and use the parameter -v /share/books:/mybooks where /share/books is a shared folder on the host that I can drop books into.

Creating the Calibre Server Docker Container

Once you have decided all of the above, you need to get the Docker container up and running:

  1. To get the Docker image onto your system, run docker pull linuxserver/calibre:latest (this command is optional as the next command will pull it down anyway).
  2. To run the Docker container use docker run --name calibre-server --security-opt seccomp=unconfined -p 48080:8080 -p 48081:8081 -e PASSWORD='password' -e TZ='Europe/London' -v /calibre-library:/config linuxserver/calibre:latest. Note that the parameter --security-opt seccomp=unconfined may be optional for you, but it was required for me to run this on a QNAP NAS. Try it without that parameter initially.

Once this is up and running, browse to http://<SERVER IP>:48080 (where <SERVER IP> is the address of the server the Docker container is running on) to access the Calibre Server Desktop app. If you’ve used the Calibre Desktop application on your local computer, the interface and the questions will be familiar to you already. But let’s run through them:

  1. Login using the username abc and password password (or whatever you set the PASSWORD environment variable to above - if you did not set a password then leave it blank). Click the OK button.

    Calibre Server Desktop App Login page
  2. On the next page choose any device you will be using.

  3. That’s it! Press the Finish button.

The Desktop app should now appear to allow you to start the Calibre Content Server.

Calibre Server Desktop App Start Content server menu button

Browse to http://<SERVER IP>:48081 (where <SERVER IP> is the address of the server the Docker container is running on) and if everything has worked, you should see this:

Calibre Server Web App initial default page

The default Calibre Server Web app page.

Every time the Docker container starts / restarts you will need to log in and start the content server again.

Be aware that you cannot use the Calibre Desktop application to connect to Calibre Server. You instead use the Calibre Server Desktop application for everything.

And that is pretty much it! Drop your books into the shared folder we used above (I used /share/books) and use the Calibre Server Desktop app to add those books to your Calibre library in the usual way.

Calibre Server Docker Container on QNAP NAS

This is going to be a fairly quick section.

I was unable to get Calibre Server running on my QNAP NAS in the ContainerStation GUI. The Calibre Server Docker container requires the Docker --security-opt seccomp=unconfined command line parameter and there is no way to specify those from ContainerStation. You can run this from the command line by connecting to your QNAP NAS using SSH and running it from the command line and following the instructions above.

Summary

The Calibre Server can be looked at as a web based Calibre Desktop app allowing you to manage your Calibre library in a central way that should avoid the risk of database corruption. If you want to have an e-book reader that can be used from any device that has a browser, then the Calibre Server Web app can be used to do that too. I have little use for the web application as I use separate applications for mobile / tablet and desktop, but I can see its use for many people particularly for offline access.