PostgreSQL
PostgreSQL is a powerful, open-source object-relational database system with over 35 years of active development.
PostgreSQL is an advanced, enterprise-class open-source relational database that supports both SQL (relational) and JSON (non-relational) querying.
Docker Compose Configuration
- Creates
docker.compose.ymlat project root with PostgreSQL service - Image:
postgres:latestofficial Docker image - Container: Named
postgres-{projectName}for easy identification - Environment Variables:
POSTGRES_USER: postgresPOSTGRES_PASSWORD: password (change in production)POSTGRES_DB:postgres-{projectName}
- Ports: Exposes port 5432 (PostgreSQL default)
- Volume: Persistent storage at
postgres-{projectName}-data:/var/lib/postgresql/data - Network: Dedicated bridge network
postgres-{projectName}-network - Command:
postgres -c 'max_connections=100'for connection limit - Healthcheck:
- Test:
pg_isready -U postgres -d postgres-{projectName} - Interval: 10s, Timeout: 5s, Retries: 5
- Start period: 30s for initialization
- Test:
Connection String Format:
postgresql://postgres:password@localhost:5432/postgres-{projectName}
