VPSFolio

2026-12-05 · trilium · notes · docker · self-hosting

Self-Host TriliumNext Notes with Docker Compose

Run TriliumNext/Trilium, the hierarchical knowledge base, in Docker with a persistent data volume, localhost binding, and Caddy HTTPS.

Bench run · 2026-12-05 Verified
TriliumNext/Trilium
Total RAM
64.8 MB
Startup
57.2 s
Port
8080
HTTP
200
triliumnext/trilium:latest · 1 container · TriliumNext/Trilium

What TriliumNext/Trilium does and what it needs

TriliumNext/Trilium is a hierarchical note-taking app built for large personal knowledge bases. Notes live in an arbitrarily deep tree, can be cloned into multiple places, and support rich text, code, canvas (Excalidraw), mind maps, geo maps, and scripting. It ships a REST API (ETAPI), a mobile web frontend, OpenID/TOTP login, and a self-hosted sync server so desktop and mobile clients stay in step.

The server is a single Node.js process. It bundles its own SQLite database inside the data directory, so there is no separate database or cache container to run. Everything persistent lives under /home/node/trilium-data inside the container. The upstream project does not publish a minimum memory figure; idle usage is modest, and memory grows with the size of the note tree, the number of concurrent clients, and heavy scripting or search workloads.

Prerequisites, ports, and volume constraints

  • Docker Engine 24+ with the Compose v2 plugin.
  • A host directory for the data. The official compose uses ./trilium-data next to the compose file; we keep that layout.
  • Port 8080 is the only port the container listens on. We bind it to 127.0.0.1:8080 so it is not reachable unencrypted from the public IP; a reverse proxy terminates TLS in front of it.
  • The data directory must be writable by the container user (UID 1000, node). If you pre-create it, chown 1000:1000 trilium-data.
  • Timezone: the official compose mounts /etc/localtime read-only. We keep that mount and also set TZ so logs and scheduled scripts use the right zone.

If you want to test without a domain, either SSH-tunnel to the host (ssh -L 8080:127.0.0.1:8080 user@host) or temporarily change the port mapping to 8080:8080 and open the firewall for your own IP only.

Production Docker Compose setup

Create the project directory and the compose file:

mkdir -p ~/trilium && cd ~/trilium
cat <<'EOF' > compose.yml
services:
  trilium:
    image: triliumnext/trilium:${TRILIUM_TAG:-latest}
    restart: unless-stopped
    ports:
      - "127.0.0.1:8080:8080"
    volumes:
      - ./trilium-data:/home/node/trilium-data
      - /etc/localtime:/etc/localtime:ro
    environment:
      - TZ=${TZ:-UTC}
EOF

Create the environment file. There are no secrets the image requires at boot — the first-run setup creates the admin account and the database — but pinning the image tag and timezone is worth doing:

cat <<'EOF' > .env
# Pin a release tag from https://github.com/TriliumNext/Trilium/releases
TRILIUM_TAG=latest
TZ=UTC
EOF

Prepare the data directory and start the stack:

mkdir -p trilium-data
sudo chown -R 1000:1000 trilium-data
docker compose up -d
docker compose logs -f trilium

Open http://127.0.0.1:8080 (or via SSH tunnel) and complete the setup wizard. Trilium asks you to create the admin user and password on first launch; that account is the only way in, so store the password in your password manager before you close the tab.

Reverse proxy, HTTPS, and first-run hardening

Trilium is a normal HTTP app with WebSocket traffic for live updates and sync. Any reverse proxy works; the important bits are forwarding Upgrade/Connection headers and not stripping the Host header. A minimal Caddy site block on the host:

notes.example.com {
    encode zstd gzip
    reverse_proxy 127.0.0.1:8080 {
        header_up Host {host}
        header_up X-Forwarded-Proto {scheme}
        header_up X-Forwarded-For {remote_host}
    }
}

Caddy handles WebSocket upgrades automatically. If you use Nginx instead, add proxy_set_header Upgrade $http_upgrade; and proxy_set_header Connection "upgrade"; to the location block, and raise client_max_body_size to something like 100m if you plan to upload large attachments or import Evernote/Markdown archives.

First-run hardening checklist:

  1. Finish setup over HTTPS, not plain HTTP, so the admin password is never sent in the clear.
  2. Enable TOTP or OpenID in Options → Security once the admin account exists.
  3. If you expose the instance publicly, put a rate limit or basic auth in front of the login page at the proxy layer; Trilium itself does not throttle login attempts.
  4. Keep the 127.0.0.1:8080 binding. If you must expose the port directly, restrict it with firewall rules scoped to your IP — the upstream compose warns that UFW does not filter Docker-published ports by default.
  5. If you use TriliumDroid or another sync client, disable automatic image updates on the server; the sync version must match between client and server.

Updating, backups, and common pitfalls

Update to a new release:

cd ~/trilium
docker compose pull
docker compose up -d
docker compose logs -f trilium

Back up the data directory. The database is SQLite inside trilium-data, so a consistent copy requires the container to be stopped (or at least idle) while you copy:

docker compose stop trilium
tar czf trilium-backup-$(date +%F).tar.gz trilium-data
docker compose start trilium

Copy the tarball off the host. Restoring is the reverse: stop the container, replace trilium-data, start it again.

Two pitfalls worth knowing up front:

  • latest is not a stable target. The official compose file itself notes that using latest may cause unintended updates. Pin TRILIUM_TAG to a release tag and bump it deliberately, especially if you sync from mobile clients.
  • Sync version mismatches break clients. TriliumNext bumped the sync version after v0.90.4, so a newer server will refuse older clients (and vice versa). If you migrate from the original zadam/trilium, versions up to v0.90.4 are compatible; anything later is not. Update server and clients together.

A third, quieter one: the data directory is owned by UID 1000. If you restore a backup as root or copy files in with sudo, the container will fail to write and you will see permission errors in the logs. Fix with sudo chown -R 1000:1000 trilium-data.


Measured in our sandbox run: total memory 64.8 MB (sum of per-container peaks over a 30s idle window after startup) across 1 container; largest container 64.8 MB; published port(s) 8080; HTTP probe returned 200. The run took 57.2s including the image download.


Verification: we ran this docker-compose stack in a disposable Docker environment and recorded the measurements above. They describe that run, not a guarantee for your host.