Docker ComposeBeginner
1Question 1 of 1
yamlHow does Docker Compose orchestrate multi-container application stacks?
Explanation & Concept
Docker Compose is a tool for defining and running multi-container Docker applications using a declarative YAML file (`docker-compose.yml`).
It automatically provisions shared internal bridge networks, mounts persistent volumes, and handles service dependencies (`depends_on`).
Code Example
yaml
version: "3.8"
services:
web:
build: .
ports:
- "3000:3000"
environment:
- DATABASE_URL=postgres://user:password@db:5432/app
depends_on:
- db
db:
image: postgres:16-alpine
environment:
POSTGRES_USER: user
POSTGRES_PASSWORD: password
POSTGRES_DB: app
volumes:
- pgdata:/var/lib/postgresql/data
volumes:
pgdata:How It Works & Key Takeaways
Services can communicate with each other using their service name (e.g. `db`) as the hostname through automatic Docker DNS resolution.
Mock Test · 1 Questions · Optional
Ready for Networking & Volumes?
Take a quick test to evaluate yourself, or move straight to the next module.
Beginner1 questions