← Back to all articles
DevOpsMay 15, 2024 · 7 min read

Docker Compose for Local Development

Simplify your development environment with Docker Compose and best practices.

E

Evan Emran

Mobile Developer & Tech Blogger

Docker Compose for Local Development

Why Docker Compose?

Docker Compose lets you define and run multi-container applications with a single YAML file. It is the fastest way to get a reproducible dev environment.

A Basic Compose File

services:
  db:
    image: postgres:16
    environment:
      POSTGRES_USER: app
      POSTGRES_PASSWORD: app
      POSTGRES_DB: app
    ports:
      - "5432:5432"

Common Commands

docker compose up -d
docker compose logs -f
docker compose down

Tips

  • Use named volumes to persist data.
  • Keep secrets out of the compose file with an .env.
  • Add healthchecks so dependent services wait correctly.