April 19, 2026
1 min read
PostgreSQL setup with Docker Compose, volume management, and creating isolated database environments for different projects.
Using Docker Compose to set up PostgreSQL in a development environment greatly simplifies version management and portability.
version: '3.8'
services:
postgres:
image: postgres:16-alpine
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: myapp
ports:
- '5432:5432'
volumes:
- postgres_data:/var/lib/postgresql/data
volumes:
postgres_data:
While the container is running, you can connect via localhost:5432.