Back to all terms
ServerNode 1Infrastructure
Infrabasic

Docker Compose

Define and run multi-container applications using a declarative YAML configuration file.

Also known as: docker-compose, compose file, Docker Compose v2, compose.yaml

Description

Docker Compose is a tool for defining and running multi-container Docker applications using a declarative YAML file (compose.yaml or docker-compose.yml). It allows developers to specify services, networks, volumes, environment variables, and dependencies in a single file, then bring the entire application stack up or down with a single command. This is particularly valuable for local development environments that mirror production architectures.

Compose supports service dependencies with depends_on and health check-based startup ordering, ensuring databases and message brokers are ready before application services start. It manages named volumes for persistent data, custom bridge networks for service isolation, and bind mounts for development hot-reloading. Environment variables can be injected from .env files, shell environment, or inline definitions with variable substitution.

Modern Docker Compose v2 (integrated as a Docker CLI plugin) supports profiles for selectively enabling services, extends for sharing common configuration, and watch mode for automatic rebuilds during development. It also supports deploy configuration for resource constraints, replicas, and restart policies, making it useful for single-node production deployments and as a stepping stone toward orchestration platforms.

Prompt Snippet

Define a compose.yaml with services for the application (build from local Dockerfile), PostgreSQL 16 with a named volume for data persistence, and Redis 7 for caching. Use healthcheck-based depends_on conditions (service_healthy) to enforce startup ordering. Configure a custom bridge network, load environment variables from a .env file with variable interpolation, set memory limits via deploy.resources.limits, and use profiles to optionally include monitoring services (Grafana, Prometheus) only in development.

Tags

dockerdocker-composemulti-containerlocal-developmentorchestration