Loading Depth Study
Preparing your workspace
Docker Compose defines multiple services, networks, volumes, environment variables, and startup configuration in one project file.
Real applications often need more than one container. Docker Compose allows developers to describe services such as an API, PostgreSQL database, Redis cache, and frontend in a YAML file. Services can share networks and volumes, and Compose can start or stop the whole application as one environment. It is especially useful for local development and testing.
A learning platform development environment can contain Next.js, Node.js, PostgreSQL, Redis, and an email testing service managed through one Compose file.
services:
api:
build: .
ports:
- "3000:3000"
environment:
DATABASE_URL: postgres://postgres:example@db:5432/app
depends_on:
- db
db:
image: postgres:17
environment:
POSTGRES_PASSWORD: example
volumes:
- pgdata:/var/lib/postgresql/data
volumes:
pgdata:Compose defines an API service and PostgreSQL service connected through the default application network with persistent database storage.