BartersmithSample report

Reviewing the official paperless-ngx compose file

A complete worked example. This is the real upstream example file — the one in paperless-ngx's own repository, which thousands of people copy verbatim. It scored 53/100. Here is every finding, why it matters in practice, and the rewrite that brings it to 100.

53/100
before
→
100/100
after
3 services · 9 findings
2 high · 4 medium · 3 low

To be clear about what this is and isn't: paperless-ngx is well-built software, and this file is a documented example, not a production configuration. Some findings are choices that are fine for a demo. The reason it's a useful sample is that it shows exactly the shape of file most people actually deploy.

1. A literal database password — high

Highdb

The Postgres password is the word "paperless"

What's there
environment:
  POSTGRES_PASSWORD: paperless
Why it bites

This is a perfectly sensible example value. The problem is that nobody changes it. The file gets copied, the stack comes up, and a Postgres instance is now listening with a documented password. Any other container on the same Docker network — including one added six months later for an unrelated reason — can connect to your document database with credentials it can guess.

Fix
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}

With POSTGRES_PASSWORD=$(openssl rand -base64 32) in a .env file that is git-ignored. The compose file becomes safe to commit; the secret lives in one place with 600 permissions.

2. A floating image tag — high

Highwebserver

The application image is pinned to latest

What's there
image: ghcr.io/paperless-ngx/paperless-ngx:latest
Why it bites

latest is not a version, it's a pointer. Every docker compose pull can move you forward by a major release without saying so. paperless-ngx is currently at 3.5.1; a jump across a major version can carry database migrations you didn't schedule, on a Tuesday, with no rollback image saved.

Fix
image: ghcr.io/paperless-ngx/paperless-ngx:3.5.1

Pinning turns an implicit upgrade into a deliberate one: change the number, pull, watch it come up, and if it misbehaves you still have the old tag to put back.

3. Nothing limits memory — medium × 3

Mediumbroker · db · webserver

Any one container can take the whole host down

Why it bites

OCR and PDF processing are memory-hungry, and they spike on large imports. Without a limit, the kernel's OOM killer picks a victim by its own rules — and it does not consult you. The usual outcome is that the database process gets killed instead of the runaway importer, which is how "one bad scan" becomes "restored from backup".

Fix
broker:     mem_limit: 512m
db:         mem_limit: 2g
webserver:  mem_limit: 2g

Now the container that misbehaves dies alone, restarts, and the database keeps its memory.

4. The app is reachable from every network — medium

Mediumwebserver

Port published on 0.0.0.0

What's there
ports:
  - "8000:8000"
Why it bites

Short syntax with no host IP means Docker binds all interfaces. On a laptop that's your café Wi-Fi. On a VPS it's the public internet the moment a firewall rule allows it — over plain HTTP, with no reverse proxy in front to add TLS, rate limiting, or a single place to look at access logs.

Fix
ports:
  - "127.0.0.1:8000:8000"

Now it's only reachable from the host itself, and a reverse proxy (Caddy, nginx) becomes the only public door — with TLS and logs on it.

5. "Running" is treated as "ready" — low × 3

Lowbroker · db · webserver

No healthchecks, and depends_on only waits for start

What's there
depends_on:
  - db
  - broker
Why it bites

This is the one that hides for months. Plain depends_on waits until the container has started — not until Postgres is accepting connections. Postgres takes a few seconds to initialise. On a warm box it's ready by the time the app asks. After a power cut, on a cold boot, the app starts first, fails to connect, and either crash-loops or comes up in a broken state.

It's invisible in testing because testing is always a warm restart.

Fix
db:
  healthcheck:
    test: ["CMD-SHELL", "pg_isready -U paperless -d paperless"]
    interval: 30s
    timeout: 5s
    retries: 5
    start_period: 30s

webserver:
  depends_on:
    db:
      condition: service_healthy
    broker:
      condition: service_healthy

Now the application waits for the database to actually answer, not merely to exist.

The hardened rewrite

All nine findings closed. The three image pins were verified to exist in their registries before being written down — not guessed at.

services:
  broker:
    image: docker.io/valkey/valkey:9.2.1-alpine
    restart: unless-stopped
    mem_limit: 512m
    healthcheck:
      test: ["CMD", "valkey-cli", "ping"]
      interval: 30s
      timeout: 5s
      retries: 3
      start_period: 10s
    volumes:
      - redisdata:/data

  db:
    image: docker.io/library/postgres:18.7
    restart: unless-stopped
    mem_limit: 2g
    environment:
      POSTGRES_DB: paperless
      POSTGRES_USER: paperless
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U paperless -d paperless"]
      interval: 30s
      timeout: 5s
      retries: 5
      start_period: 30s
    volumes:
      - pgdata:/var/lib/postgresql

  webserver:
    image: ghcr.io/paperless-ngx/paperless-ngx:3.5.1
    restart: unless-stopped
    mem_limit: 2g
    depends_on:
      db:
        condition: service_healthy
      broker:
        condition: service_healthy
    ports:
      - "127.0.0.1:8000:8000"
    healthcheck:
      test: ["CMD-SHELL", "python3 -c \"import urllib.request,sys; sys.exit(0 if urllib.request.urlopen('http://localhost:8000/accounts/login/', timeout=5).status == 200 else 1)\""]
      interval: 60s
      timeout: 10s
      retries: 3
      start_period: 120s
    volumes:
      - data:/usr/src/paperless/data
      - media:/usr/src/paperless/media
      - ./export:/usr/src/paperless/export
      - ./consume:/usr/src/paperless/consume
    env_file: docker-compose.env
    environment:
      PAPERLESS_REDIS: redis://broker:6379
      PAPERLESS_DBHOST: db
      PAPERLESS_DBENGINE: postgresql

volumes:
  data:
  media:
  pgdata:
  redisdata:

What I deliberately did not change

Paperless's own docker-compose.env and .env split is sensible and I left it alone — the only change is that the database password now comes from a file instead of the compose. The relative ./export and ./consume mounts are intentional, documented behaviour for importing files, so they stayed. And I did not add a reverse proxy config: that depends on what you already run, and guessing would have made the file worse rather than better.

A review that changes everything is as useless as one that changes nothing. The point is to change only what has a reason.

Want this for your own stack?

Check it free at bartersmith.com first. If you want the full treatment — a prioritised report on your file plus a hardened rewrite with every version pin verified — that's what the paid review is for.