How to Install Komga on a VPS with Docker: Your Own Comics, Manga, and Ebook Library
Comic and manga collections have a bad habit: they scatter. Some CBZ files live on a laptop, some CBR files on an external drive, a few PDFs on a phone, and the rest God knows where. When you want to pick up where you left off, you spend your time hunting for the file first, then reading it in a generic file viewer that doesn't remember your last page. Ebooks end up the same way — the titles are there, but there's no tidy catalog, no covers to browse, and no way to share them with family without sending files one by one.
Komga sorts that mess out by being a book-focused media server. This open source project manages comics, manga, bandes dessinées, magazines, and ebooks in libraries you can browse from a browser, complete with a built-in web reader, reading-progress tracking, and separate user accounts. Every file stays on your own server, so no third-party service gets to peek at your collection. This guide installs it with Docker Compose, then secures it behind Nginx with HTTPS.
Prerequisites
- A Linux VPS with Docker and Docker Compose v2 installed.
- SSH access to the VPS with
sudorights. - A domain already pointing at the VPS IP if you want HTTPS access, for example
comics.example.com. This article uses that domain as an example; replace it with your own. Without a domain, you can still test the install athttp://YOUR-VPS-IP:25600. - A collection of comic or ebook files in formats Komga recognizes, such as CBZ, CBR, EPUB, or PDF. Have them ready on your computer to upload later.
Check Docker and Compose first, then find out your account's UID and GID — Komga runs as a specific user, and these numbers go into the configuration:
docker --version
docker compose version
id
Expected result: both Docker commands print version numbers without errors, and id shows a line like uid=1000(username) gid=1000(username). Note both numbers down; this article uses 1000:1000, and you should adjust them if yours differ.
Step 1: prepare the config and data folders
Create a working folder at /opt/komga with two subfolders: config for Komga's database and settings, and data for your book files:
sudo mkdir -p /opt/komga/config /opt/komga/data
sudo chown -R 1000:1000 /opt/komga
Replace 1000:1000 with the UID and GID from your id output if they differ. This step matters because Komga's official documentation stresses that the volume folders on the host must be owned by the same user the container runs as — otherwise Komga can't write its database or read your collection. One warning from the same documentation: the /config folder must sit on a local filesystem. Don't put it on a network share like CIFS or NFS, or Komga will refuse to run.
The data folder is what gets mapped to /data inside the container. All your comic and ebook files will live there.
Step 2: write the Compose file
Move into the working folder and create compose.yml:
cd /opt/komga
sudo nano compose.yml
Fill it with the following configuration:
services:
komga:
image: gotson/komga:latest
container_name: komga
user: "1000:1000"
restart: unless-stopped
ports:
- "25600:25600"
volumes:
- /opt/komga/config:/config
- /opt/komga/data:/data
environment:
- TZ=Asia/Jakarta
This follows the official example in Komga's documentation: the gotson/komga image (also published on GitHub Container Registry), port 25600 for the web interface and API, two bind mounts to /config and /data, and user: "1000:1000". The latest tag follows the newest commit; the docs also offer MAJOR.x tags (for example 1.x) and exact x.y.z version tags if you'd rather pin a specific release. The TZ variable sets the container's timezone — fill in your own; the example above uses Asia/Jakarta.
What's missing from this file matters just as much: there's no password or key to fill in up front. The administrator account is created through the web interface in step 4, not through environment variables.
Step 3: start and check the container
Start the stack:
sudo docker compose up -d
sudo docker compose ps
Expected result: the komga container shows as running (or Up). Komga runs on Java, so give the first start a minute or two while it prepares its database. Check the logs if you want confirmation:
sudo docker compose logs --tail=30 komga
Expected result: log lines showing the server listening on port 25600, with no errors in sight. Next, test from inside the VPS that the web interface responds:
curl -s -o /dev/null -w "%{http_code}\n" http://localhost:25600
Expected result: the number 200. If you get 000 instead, the container may still be starting, or port 25600 may already be taken by another application — see the Troubleshooting section below.
Step 4: create the administrator account and your first library
Open http://YOUR-VPS-IP:25600 in a browser. The first screen asks you to create an administrator account: enter an email address and a password, then save. This account holds full control over server settings, libraries, and user management — store its credentials somewhere safe, because there's no "forgot password" button to rescue you without another admin account.
Once you're in, create your first library:
- Click Add Library on the main screen, or the add button next to Libraries in the left sidebar.
- On the General tab, fill in Name — for example
MangaorIndonesian Comics— then click Browse on Root folder and pick a folder inside/data. If your whole collection sits directly in/data, pick that folder; if you split it by category, pick the subfolder, for example/data/manga. - Set the remaining tabs to your liking (such as the scan interval and which metadata to import), then click Add.
Komga then scans that folder: files get matched into series and books, covers are extracted, and embedded metadata is read. This runs in the background; a large collection takes a while, and you can watch the progress in the task list in the interface.
Before a library can show anything, the files need to be in the data folder. Copy your collection into /opt/komga/data from your computer, for example with scp:
scp -r ~/Collection/Manga/* root@YOUR-VPS-IP:/opt/komga/data/manga/
Adjust the paths and address to your own. Once the copy finishes, Komga will pick the files up on its next scan — or trigger a manual scan from the library menu if you don't want to wait for the automatic interval.
Step 5: put Nginx with HTTPS in front
Don't leave Komga on plain HTTP at port 25600 if this server will be reachable from the internet — your login page and reading sessions deserve HTTPS. Create /etc/nginx/sites-available/komga:
server {
listen 80;
server_name comics.example.com;
location / {
proxy_pass http://127.0.0.1:25600;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Enable the configuration and issue a certificate:
sudo ln -s /etc/nginx/sites-available/komga /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
sudo certbot --nginx -d comics.example.com
Expected result: nginx -t answers test is successful, and Certbot reports the certificate was issued. After that, reach Komga at https://comics.example.com and sign in with the administrator account you created in step 4.
Step 6: add users and keep the install healthy
One Komga server can serve a whole household without everyone peeking at each other's reading progress. As administrator, you can create additional user accounts from the settings menu, then restrict which libraries each account can access. Family members can have their own shelves, and a guest can be limited to a single library.
Third-party reader apps that support the Komga API can also connect to this server, so your collection isn't locked into the built-in web reader — check the server settings for the connection details your chosen app needs.
For routine maintenance, these two things are enough:
cd /opt/komga
sudo docker compose pull && sudo docker compose up -d
That pulls the newest image and recreates the container. Your database and settings are safe because everything lives in /opt/komga/config, not inside the container. Even so, the config folder is the one that must be part of your regular backups — losing it means losing every account, library, and reading progress record. The data folder needs backing up too, of course, since that's where the books themselves live.
If Komga ever complains about running out of memory (OutOfMemoryException in the logs) on a very large collection, the official documentation has the fix: add the variable JAVA_TOOL_OPTIONS=-Xmx2g to the environment section of compose.yml, then restart the container. The 2g value can go higher to match your VPS RAM.
Troubleshooting
curl returns 000 or the browser can't connect.
Check the container is running with sudo docker compose ps. If it shows Up but still doesn't respond, wait a little longer — Komga's first start on Java isn't as instant as a static app. Check the logs with sudo docker compose logs --tail=50 komga. If the container won't come up at all, port 25600 is probably already used by another application — check with sudo ss -tlnp | grep 25600, then change the port mapping in compose.yml to "25601:25600" and restart with sudo docker compose up -d.
The library is empty even though the files were copied.
Almost always a folder-ownership problem. Make sure the host folders are owned by the same UID/GID as user: in compose.yml: sudo chown -R 1000:1000 /opt/komga (adjust the numbers). Then check the library's root folder in its settings — it must point at the path inside the container (/data/...), not the host path (/opt/komga/data/...). Finally, trigger a manual scan from the library menu.
Komga stops with a message that the database must be on a local filesystem.
This appears when /config sits on a network share. The official documentation forbids CIFS/NFS for this folder. Move the config folder to the VPS local disk, update the volume in compose.yml, and restart.
The first screen says the server is already claimed.
That means the database already contains a user — this happens when Komga ran and generated a default user before you had a chance to claim it. According to the official FAQ, the way out is to delete the database and start over. In this Docker install, the database lives inside the /config volume (the /opt/komga/config folder on the host). Stop the container, empty the config folder, and start again — but be aware this wipes every account and library configuration, so only do it when there's genuinely nothing worth keeping yet.
A large collection runs Komga out of memory.
Add JAVA_TOOL_OPTIONS=-Xmx2g to environment in compose.yml (the docs use -Xmx4g as their example), then run sudo docker compose up -d. If that's still not enough, raise the value to match your VPS RAM.
Summary table
| Component | Function | Port | Notes |
|---|---|---|---|
| komga | Comics/manga/ebook library server | 25600 → 25600 | Image gotson/komga:latest |
| /config | Database + Komga settings | Volume /opt/komga/config |
Must be a local filesystem; must be backed up |
| /data | Book files (CBZ, CBR, EPUB, PDF) | Volume /opt/komga/data |
Library root folders point here |
| Nginx on host | Reverse proxy + HTTPS | 80 / 443 | Access via https://comics.example.com |
| compose.yml | The only config file | /opt/komga/compose.yml |
user: "1000:1000", TZ=Asia/Jakarta |
Checklist before you finish
- The
komgacontainer is running andcurl http://localhost:25600returns200. - The administrator account is created and you can sign in at
https://comics.example.com(replace with your domain). - The first library is created, files are copied into
/opt/komga/data, and series with covers appear after the scan. - Ownership of
/opt/komgamatches the UID/GID incompose.yml. - The
/opt/komga/configfolder is included in your regular backups.
Which collection will you move to Komga first — the manga piling up on a hard drive, old comics, or ebooks you haven't gotten around to reading? And will you share this server with family, or keep it for yourself? Tell us in the comments, and if any step above doesn't work on your VPS, paste the error message so we can work through it together.
Read also: the Rnevio guide how to install Navidrome on a VPS for your own music server covers another self-hosted media server that pairs well with this book library, while the companion guide in this batch is the Typesense guide for a self-hosted search engine on a VPS.


Diskusi
Ada pertanyaan atau pengalaman yang ingin dibagikan?
Komentar ditinjau sebelum ditampilkan. Mari berdiskusi dengan sopan dan sesuai topik.
Tulis komentar