Docker Compose for Local Development
Linking Go service with PostgreSQL and Redis
Why Docker Compose?
Docker Compose orchestrates multiple containers (app, database, cache, message broker) for local development, reproducing a production-like environment without manual service setup.
docker-compose.yml structure
Define services, networks, and volumes in a YAML file:
services:
app:
build: .
ports: ["8080:8080"]
environment:
- DATABASE_URL=postgres://app:pass@db/mydb
depends_on: [db]
db:
image: postgres:15
environment:
POSTGRES_USER: app
POSTGRES_PASSWORD: pass
POSTGRES_DB: mydb
volumes:
- pgdata:/var/lib/postgresql/data
volumes:
pgdata:All lessons in this course
- Multi-Stage Docker Builds for Go
- Environment Config and Secrets
- Docker Compose for Local Development
- Health Checks and Production Tuning