VPSFolio

2026-11-19 · linkwarden · bookmarks · docker · self-hosting

Self-Host Linkwarden with Docker Compose: Bookmarks, Archived

Run Linkwarden with Docker Compose: Postgres, Meilisearch, screenshot/PDF archiving, NextAuth, and a Caddy reverse proxy for HTTPS.

Bench run · 2026-11-24 Verified
linkwarden/linkwarden
Total RAM
550.0 MB
Startup
189.9 s
Port
3000
HTTP
200
Per container linkwarden 475.8 MB · meilisearch 44.0 MB · postgres 30.3 MB
ghcr.io/linkwarden/linkwarden:latest · 3 containers · linkwarden/linkwarden

What Linkwarden does and what it needs

Linkwarden is a collaborative bookmark manager that doesn’t just store URLs. When you save a page it captures a screenshot, a PDF, and a single-file HTML copy, so the content survives link rot. You get collections, sub-collections, tags, a reader view with highlights and annotations, full-text search, public sharing, and per-member permissions. There’s a browser extension, native mobile apps, and an API.

The stack is three containers:

  • linkwarden — the Next.js app (port 3000). It also runs a Playwright browser to render screenshots and PDFs.
  • postgres — the database. Everything lives here.
  • meilisearch — the search index behind full-text search.

Archived files (screenshots, PDFs, HTML) go to the /data/data volume. The upstream project does not publish a minimum RAM figure. In practice, idle memory is modest, but each archive job spawns a headless browser — concurrent jobs are the real memory driver. If you archive a lot of links at once, raise MAX_WORKERS deliberately and watch memory, or leave it low.

Prerequisites, ports, and volume constraints

  • Docker Engine 24+ with the Compose v2 plugin.
  • A domain pointed at your server if you want HTTPS (recommended).
  • Port 3000 is the app’s HTTP port. We bind it to 127.0.0.1:3000 so only the reverse proxy reaches it.
  • Two persistent volumes matter: pgdata (Postgres) and linkwarden_data (archives). A third, meili_data, holds the search index — it can be rebuilt, but back it up anyway to avoid a reindex.

Generate secrets before you start. You need a Postgres password, a NextAuth secret, and a Meilisearch master key:

openssl rand -hex 32   # POSTGRES_PASSWORD
openssl rand -hex 32   # NEXTAUTH_SECRET
openssl rand -hex 32   # MEILI_MASTER_KEY

Production Docker Compose setup

Create the project directory and the .env file first. NEXTAUTH_URL must be the public URL of your instance plus /api/v1/auth — NextAuth uses it to build callback URLs, so a wrong value breaks login.

mkdir -p /opt/linkwarden && cd /opt/linkwarden
cat <<'EOF' > .env
# Public URL of the instance, including the auth path
NEXTAUTH_URL=https://links.example.com/api/v1/auth
NEXTAUTH_SECRET=REPLACE_WITH_OPENSSL_RAND_HEX_32

# Database
POSTGRES_PASSWORD=REPLACE_WITH_OPENSSL_RAND_HEX_32

# Meilisearch
MEILI_HOST=http://meilisearch:7700
MEILI_MASTER_KEY=REPLACE_WITH_OPENSSL_RAND_HEX_32

# Optional tuning
TZ=UTC
MAX_WORKERS=1
NEXT_PUBLIC_DISABLE_REGISTRATION=false
EOF
chmod 600 .env

Now the compose file. It follows the upstream layout but uses named volumes and a localhost-bound port:

cat <<'EOF' > compose.yml
services:
  postgres:
    image: postgres:16-alpine
    restart: unless-stopped
    environment:
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      TZ: ${TZ:-UTC}
    volumes:
      - pgdata:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U postgres"]
      interval: 10s
      timeout: 5s
      retries: 10

  meilisearch:
    image: getmeili/meilisearch:v1.13.3
    restart: unless-stopped
    environment:
      MEILI_MASTER_KEY: ${MEILI_MASTER_KEY}
      MEILI_NO_ANALYTICS: "true"
      TZ: ${TZ:-UTC}
    volumes:
      - meili_data:/meili_data

  linkwarden:
    image: ghcr.io/linkwarden/linkwarden:latest
    restart: unless-stopped
    depends_on:
      postgres:
        condition: service_healthy
      meilisearch:
        condition: service_started
    environment:
      NEXTAUTH_URL: ${NEXTAUTH_URL:-http://localhost:3000/api/v1/auth}
      NEXTAUTH_SECRET: ${NEXTAUTH_SECRET}
      DATABASE_URL: postgresql://postgres:${POSTGRES_PASSWORD}@postgres:5432/postgres
      MEILI_HOST: ${MEILI_HOST:-http://meilisearch:7700}
      MEILI_MASTER_KEY: ${MEILI_MASTER_KEY}
      MAX_WORKERS: ${MAX_WORKERS:-1}
      NEXT_PUBLIC_DISABLE_REGISTRATION: ${NEXT_PUBLIC_DISABLE_REGISTRATION:-false}
      TZ: ${TZ:-UTC}
    ports:
      - "127.0.0.1:3000:3000"
    volumes:
      - linkwarden_data:/data/data

volumes:
  pgdata:
  meili_data:
  linkwarden_data:
EOF

Start it:

docker compose up -d
docker compose logs -f linkwarden

Wait for the app to report ready, then open http://127.0.0.1:3000 through an SSH tunnel (ssh -L 3000:127.0.0.1:3000 user@server) to create the first account. That first user becomes the admin.

Reverse proxy, HTTPS, and first-run hardening

Linkwarden is a Next.js app behind a single HTTP port. It doesn’t need WebSocket upgrade headers for normal use, but it does need correct forwarded headers so NextAuth generates https:// callbacks. Caddy handles this automatically. A minimal Caddyfile:

links.example.com {
    encode zstd gzip
    reverse_proxy 127.0.0.1:3000
}

Reload Caddy and confirm https://links.example.com loads. If login redirects to http:// or fails with a callback error, the culprit is almost always NEXTAUTH_URL — it must match the public HTTPS URL exactly, including /api/v1/auth.

Upload limits: Linkwarden accepts image and PDF uploads, and archives can be large. If you front it with Nginx instead of Caddy, set client_max_body_size 50m; (or higher) and pass X-Forwarded-Proto $scheme and X-Forwarded-For. Caddy needs no extra config here.

First-run hardening:

  1. Create your admin account immediately after first boot.
  2. Set NEXT_PUBLIC_DISABLE_REGISTRATION=true in .env and docker compose up -d to recreate the container. This closes public signup; add users from the admin panel instead.
  3. Keep MEILI_MASTER_KEY and NEXTAUTH_SECRET out of version control. The .env file is chmod 600 for a reason.
  4. If you expose the instance publicly, consider ALLOW_PRIVATE_NETWORK_ACCESS=false (the default) so users can’t use the archiver to probe your internal network.

Updating, backups, and common pitfalls

Update by pulling the new image and recreating:

docker compose pull
docker compose up -d
docker compose logs -f linkwarden

Back up the two volumes that hold irreplaceable data — Postgres and the archive files:

docker compose exec -T postgres pg_dump -U postgres postgres > backup-$(date +%F).sql
docker run --rm -v linkwarden_linkwarden_data:/data -v $(pwd):/backup alpine \
  tar czf /backup/linkwarden-data-$(date +%F).tar.gz -C /data .

Restore by reversing those commands: psql the dump back into a fresh Postgres, and untar the archive volume. Test a restore on a throwaway stack before you need it.

Two pitfalls worth knowing:

  • Archive jobs stall or time out. The headless browser is the fragile part. If screenshots stop appearing, check docker compose logs linkwarden for Playwright errors. Raising BROWSER_TIMEOUT helps on slow pages; lowering MAX_WORKERS to 1 helps on memory-constrained hosts. Don’t set both high at once.
  • Search returns nothing after a restore. Meilisearch’s index lives in meili_data. If you restored Postgres but not Meilisearch, the app has links but no index. Either restore meili_data too, or trigger a reindex from the admin settings. This is why backing up all three volumes is cheaper than debugging a half-restored stack.

Measured in our sandbox run: total memory 550.0 MB (sum of per-container peaks over a 30s idle window after startup) across 3 containers; largest container 475.8 MB; published port(s) 3000; HTTP probe returned 200. The run took 189.9s including the image download. Required secret(s) MEILI_MASTER_KEY, NEXTAUTH_SECRET, POSTGRES_PASSWORD were generated for the test run, as the tutorial instructs. Container breakdown: linkwarden 475.8 MB, meilisearch 44.0 MB, postgres 30.3 MB.


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.