[PostgreSQL in Docker for Production: Complete Guide](https://api.daily.dev/r/8YTdGJN1I)**
**
> Running PostgreSQL in Docker for production requires overriding several Docker defaults that conflict with Postgres internals. Starting with PostgreSQL 18, the official image moved PGDATA into version-specific subdirectories and changed the volume mount target to /var/lib/postgresql instead of /var/lib/postgresql/data. Docker's default 64 MB /dev/shm limit can cause queries to fail under real load, so shm_size should be set to 1gb or higher. The default 10-second SIGTERM-to-SIGKILL window can kill Postgres mid-checkpoint, so stop_grace_period should be raised to 60 or 120 seconds. PgBouncer in transaction pooling mode should sit in front of Postgres to absorb connection bursts, keeping max_connections around 100-150. Backups should use pg_dump -Fc or continuous WAL archiving with pgBackRest or WAL-G, never raw file copies of a running PGDATA directory.
