Docker for Local Development
/ 1 min read
Table of Contents
Docker makes it easy to spin up consistent development environments without polluting your host machine.
A Simple Compose File
services: db: image: postgres:16 environment: POSTGRES_PASSWORD: dev POSTGRES_DB: myapp ports: - "5432:5432" volumes: - pgdata:/var/lib/postgresql/data
redis: image: redis:7-alpine ports: - "6379:6379"
volumes: pgdata:Run docker compose up -d and you have a Postgres database and Redis instance ready to go.
Tips
- Use volumes for data persistence across restarts
- Pin image versions to avoid surprises
- Use
.envfiles to keep configuration out of your compose file - Add healthchecks so dependent services wait properly
Docker Compose is one of those tools that pays for itself on day one.