Run your own ebook library
A beginner's guide to self-hosting your books with calibre-zen and Docker, from an empty folder to reading on every device in the house.
By the end you have a private library that any browser in the house can open, with a reader built in. It takes about fifteen minutes, most of it waiting for a download.
What you get
Section titled “What you get”- Your books in any browser. Phones, tablets and computers can search, read and download them, with no app to install.
- Plain files you own. The library is an ordinary calibre library, a folder of books and one
metadata.db. calibre and calibre-zen on a desktop can open the same folder, so nothing locks you in. - A login. Only the people you choose can see and change your books.
- A drop folder. Copy a book into it and it moves into your library a few seconds later.
What you need
Section titled “What you need”- A computer that stays on. A NAS, a Raspberry Pi 4 or 5, a small PC or an old laptop all work. Intel and ARM are both fine.
- Docker with Compose. Most NAS systems have it in their app store. On Linux, the official install script from Docker sets up both.
- Some ebooks. EPUB, PDF, MOBI, AZW3 and CBZ all work. Books with DRM do not open in any reader outside the store that sold them.
The download is about 420 MB, because the image carries all of calibre.
Set it up
Section titled “Set it up”-
Make a folder for it and step inside. Everything lives here, your books included.
Terminal window mkdir calibre-zen && cd calibre-zen -
Download the ready Compose file.
Terminal window curl -fsSLO https://raw.githubusercontent.com/purplecandy/calibre-zen/zen/packaging/docker/compose.yaml -
Pick a password and save it next to the Compose file. Use your own in place of the example.
Terminal window echo 'CALIBRE_ZEN_PASSWORD=a-long-password-of-your-own' > .env -
Check who should own the books. Run
idand look at the numbers afteruid=andgid=. If they are not both1000, changePUIDandPGIDincompose.yamlto match. -
Start it.
Terminal window docker compose up -dThe first start makes three folders next to the Compose file:
libraryfor your books,configfor settings andadd-booksfor new books.
Open it
Section titled “Open it”Go to http://your-server:8080 in a browser and sign in as reader with your password. Use the server’s address in place of your-server. On Linux, hostname -I shows it.
The library is empty for now. That comes next.
Add your books
Section titled “Add your books”- Drop them in. Copy books into the
add-booksfolder. Each one moves into your library a few seconds later. - Upload them. Once you are signed in, the web app has a button to add books from the device you are on.
- Bring a calibre library you already have. Stop the container, then put your library in the
libraryfolder, or point./libraryincompose.yamlat it. It is the folder that holdsmetadata.db. Nothing in it is moved or renamed.
Read on every device
Section titled “Read on every device”- Phones and tablets. Open the address and read in the browser. Adding it to your home screen makes it feel like an app.
- Reading apps. Apps that speak OPDS, such as KOReader, can browse the library at
http://your-server:8080/opdswith the same username and password. A few apps only manage the simpler basic sign in, which the reverse proxy section below turns on. - E-readers with a browser. Kobo and Kindle browsers can open the address and download books in a format the device reads.
Reach it away from home
Section titled “Reach it away from home”Leave this for later if you only read at home.
- The easy way is a private network such as Tailscale or WireGuard. Your phone joins it, and the library stays off the open internet with no ports to open. Share your library over the internet walks through it with Tailscale.
- The public way is a reverse proxy such as Caddy, Traefik or nginx, which adds HTTPS. Basic sign in suits it best, and one line under the service in
compose.yamlturns it on. SetCALIBRE_ZEN_URL_PREFIXtoo if you serve it under a path like/books.
command: ['--auth-mode', 'basic']Never open port 8080 to the internet without HTTPS in front of it. The password would travel in the clear.
Keep it safe
Section titled “Keep it safe”- Back up two folders.
libraryholds every book and its details, andconfigholds your settings and users. Stop the container first, or copy them while nobody is adding books, so the database is not caught mid-change. - Update in one line.
docker compose pull && docker compose up -dgets the newest release. Your books and settings stay where they are. - Add more people.
docker exec -it calibre-zen zen-entrypoint --manage-usersopens a menu to add, change or remove users.
If something goes wrong
Section titled “If something goes wrong”docker compose logs -f shows what the server is doing, and the fixes below cover the usual reasons it stops.
- It will not start and mentions the password. The
.envfile is missing, or is not in the same folder ascompose.yaml. - It says it cannot write to the library. The user in
PUIDandPGIDhas to own the books. Runidagain and match them. - It says another program has the library open. calibre is still running on that library somewhere. Close it and start the container again.
Every setting, from time zones to sharing a library with a group, is in the Docker guide on GitHub. Questions are welcome on Reddit or GitHub Issues.