Docker Compose
Prerequisites
Section titled “Prerequisites”- Docker Engine 20.10+
- Docker Compose v2+
Single Service Setup
Section titled “Single Service Setup”A complete Sonarr deployment with PostgreSQL, PrepArr init, the Sonarr app, and the PrepArr sidecar:
services: postgres: image: postgres:16-alpine environment: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres123 POSTGRES_DB: servarr volumes: - postgres_data:/var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready -U postgres"] interval: 10s timeout: 5s retries: 5
sonarr-init: image: ghcr.io/robbeverhelst/preparr:latest command: ["bun", "run", "dist/index.js", "--init"] environment: POSTGRES_HOST: postgres POSTGRES_PASSWORD: postgres123 SERVARR_URL: http://sonarr:8989 SERVARR_TYPE: sonarr SERVARR_ADMIN_PASSWORD: adminpass CONFIG_PATH: /config/sonarr-config.json volumes: - sonarr_config:/config - ./sonarr-config.json:/config/sonarr-config.json:ro depends_on: postgres: condition: service_healthy
sonarr: image: linuxserver/sonarr:latest ports: - "8989:8989" environment: - PUID=1000 - PGID=1000 - TZ=UTC volumes: - sonarr_config:/config - ./tv:/tv - ./downloads:/downloads depends_on: sonarr-init: condition: service_completed_successfully
sonarr-sidecar: image: ghcr.io/robbeverhelst/preparr:latest environment: POSTGRES_HOST: postgres POSTGRES_PASSWORD: postgres123 SERVARR_URL: http://sonarr:8989 SERVARR_TYPE: sonarr SERVARR_ADMIN_PASSWORD: adminpass CONFIG_PATH: /config/sonarr-config.json CONFIG_WATCH: "true" CONFIG_RECONCILE_INTERVAL: "60" HEALTH_PORT: "9001" LOG_LEVEL: info ports: - "9001:9001" volumes: - sonarr_config:/config - ./sonarr-config.json:/config/sonarr-config.json:ro depends_on: - sonarr healthcheck: test: ["CMD", "curl", "-f", "http://localhost:9001/health"] interval: 30s timeout: 10s retries: 3
volumes: postgres_data: sonarr_config:Container roles
Section titled “Container roles”| Container | Purpose | Lifecycle |
|---|---|---|
postgres | Shared database | Persistent, always running |
sonarr-init | Database setup, config.xml generation | Runs once, then exits |
sonarr | The Sonarr application | Always running |
sonarr-sidecar | Configuration reconciliation | Always running alongside Sonarr |
Startup order
Section titled “Startup order”Docker Compose depends_on conditions enforce the correct order:
- PostgreSQL starts and passes its health check
- Init container runs, creates databases and config.xml, then exits
- Sonarr starts using the prepared config
- Sidecar starts and begins reconciling configuration
Multi-Service Setup
Section titled “Multi-Service Setup”For a full Prowlarr + Sonarr + Radarr + qBittorrent stack, see the Multi-Service Stack guide.
Common Operations
Section titled “Common Operations”# Start all servicesdocker compose up -d
# View sidecar logsdocker compose logs -f sonarr-sidecar
# Restart sidecar after config changesdocker compose restart sonarr-sidecar
# Stop everythingdocker compose down
# Stop and remove volumes (full reset)docker compose down -vUpdating Configuration
Section titled “Updating Configuration”If CONFIG_WATCH=true (default), the sidecar detects config file changes automatically. Otherwise:
- Edit your JSON config file
- Restart the sidecar:
docker compose restart sonarr-sidecar
Data Persistence
Section titled “Data Persistence”| Data | Storage | Notes |
|---|---|---|
| PostgreSQL data | Named volume (postgres_data) | Survives container restarts |
| Config files (JSON) | Bind mount from host | Read-only, version controlled |
| config.xml | Named volume (sonarr_config) | Regenerated by init container |
| Media files | Bind mount from host | Sonarr reads/writes directly |
PrepArr is stateless. If you lose the sonarr_config volume, run the init container again to regenerate everything.