Skip to content

Docker Compose ​

The shipped docker-compose.yaml starts the proxy with PostgreSQL, Redis, persistent volumes, and health-gated startup.

Layout ​

yaml
services:
  llm-proxy:   # ghcr.io/zwldarren/llm-proxy:stable   → 8080:8080
  db:          # postgres:18                          → volume postgres_data
  redis:       # redis:8-alpine                       → volume redis_data

Before you start ​

docker compose up -d works out of the box. POSTGRES_PASSWORD defaults to llmproxy, and .env is optional. Copy the template when you want to override defaults:

bash
cp .env.example .env

.env.example lists every supported variable; uncomment the ones you need.

Set a real password before the first start

Postgres applies POSTGRES_PASSWORD only when the postgres_data volume is first initialized. The default llmproxy is fine for local testing, but for anything reachable beyond localhost, set your own value in .env before the first docker compose up. Changing it later requires recreating the volume.

Key details ​

  • The database URL is preconfigured as postgresql+asyncpg://llmproxy:<POSTGRES_PASSWORD>@db:5432/llmproxy.
  • POSTGRES_PASSWORD defaults to llmproxy and is interpolated into both DATABASE_URL and Postgres initialization. Override it in .env.
  • .env is optional (required: false). Without it, the stack starts with built-in defaults.
  • Startup order is gated by healthchecks: the proxy starts only after pg_isready succeeds and redis-cli ping responds.
  • Redis is enabled (REDIS_ENABLED=true, REDIS_URL=redis://redis:6379) with shared rate limiting and config caching turned on (REDIS_RATE_LIMIT_ENABLED=true, REDIS_CACHE_ENABLED=true). This satisfies the requirements for multi-worker mode. See PostgreSQL & Redis.
  • Redis runs with allkeys-lru eviction and AOF persistence. Everything the proxy stores in Redis can be reconstructed if evicted.

Environment ​

Compose reads .env for variable interpolation and passes the same file to the container via env_file when present. Put POSTGRES_*, JWT_SECRET, ENCRYPTION_KEY, TRUSTED_PROXIES, pool settings, and REDIS_* flags in .env.

Full list: Environment Variables.

Image tags ​

Published to GHCR by CI:

TagMeaning
stableNewest tagged release. Pinned by default in compose; recommended for production
latestNewest build from main
0.5.3 (pep440)Exact release, best for version pinning
mainBranch build
pr-<n>Pull-request builds (build-only, not pushed)

Release images are signed with cosign. Verify by digest if your registry policy requires it.

Ports and exposure ​

Only llm-proxy publishes a port (8080). db and redis stay on the internal network. Put a reverse proxy with TLS in front of llm-proxy before exposing it to the internet. See Reverse Proxy & TLS.

Healthchecks and restarts ​

db and redis define healthchecks, while llm-proxy does not in the shipped compose file (even though the app exposes health endpoints). None of the services set a restart: policy, so the stack stays down after a host reboot. Add both yourself:

yaml
healthcheck:
  test: ["CMD", "python", "-c", "import urllib.request;urllib.request.urlopen('http://127.0.0.1:8080/api/health/ready')"]
  interval: 30s
  timeout: 5s
  retries: 3
restart: unless-stopped

Updating ​

bash
docker compose pull
docker compose up -d

Database migrations run automatically at startup. See Upgrades & Backups for pre-upgrade checks.

Where data lives ​

DataLocation
Providers, models, keys, users, logs, usage, secretsPostgreSQL volume postgres_data (mount point /var/lib/postgresql)
Routing/session state, response store, AOFRedis volume redis_data

The proxy container itself is stateless and mounts no volumes. Running docker compose down keeps all data intact as long as the named volumes remain.

MIT licensed