db: image: postgres:13 volumes: - postgres_data:/var/lib/postgresql/data environment: POSTGRES_DB: mydb POSTGRES_USER: user POSTGRES_PASSWORD: password
"A Developer's Essential Guide to Docker Compose" by Emmanouil Gkatziouras offers a comprehensive guide to managing multi-container applications, covering local setup, networking, and cloud deployment on AWS and Azure. The book focuses on practical scenarios, including microservices development, CI/CD integration, and migrating to Kubernetes. The official code repository for the book is available on GitHub . A Developer's Essential Guide to Docker Compose - GitHub
From docker run to production-like stacks By [Your Name] Version 1.0 | Includes practical examples & CLI cheat sheet
env_file: - ./config/common.env
services: app: build: ./app ports: - "3000:3000" environment: - NODE_ENV=development depends_on: - db - redis
To stop and remove containers, networks, and images created by up :
One command to spin up a dev environment identical to production dependencies (databases, caches, queues). a developer's essential guide to docker compose pdf
Port is already in use. Solution: Ensure no other service on your host machine is using the mapped port (e.g., port 80 or 5432). You can change the host port in the mapping (e.g., "8080:80" ).
| Problem | Command to investigate | |---------|------------------------| | Container exits immediately | docker compose logs <service> | | Can't connect between services | docker compose exec app ping db | | Volume not persisting | docker compose exec db ls -la /var/lib/postgresql/data | | Port already in use | docker compose down then lsof -i :3000 | | Image build failing | docker compose build --progress=plain |
volumes: db_data:
Tip: Always use the -d flag for long-running services to keep your terminal free.
docker compose down
Docker Compose is the standard for local multi-container development, allowing you to define and manage an entire application stack—including databases, caches, and web servers—using a single YAML file. Understanding the Core Architecture A Developer's Essential Guide to Docker Compose -