skip to content
Johannes Binder

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

  1. Use volumes for data persistence across restarts
  2. Pin image versions to avoid surprises
  3. Use .env files to keep configuration out of your compose file
  4. Add healthchecks so dependent services wait properly

Docker Compose is one of those tools that pays for itself on day one.