Docker Compose
By Docker, Inc.
Docker Compose is a tool for defining and running multi-container Docker applications using a single YAML configuration file that specifies each service, its image or build context, networking, and volumes. A single command then builds and…
Definition
Docker Compose is a tool for defining and running multi-container Docker applications using a single YAML configuration file that specifies each service, its image or build context, networking, and volumes. A single command then builds and starts all defined services together, making it a standard way to run local development environments composed of multiple interdependent containers. A single command builds and starts all defined services together with a shared network so containers can reach each other by service name, and its functionality is now integrated directly into the Docker CLI as the `docker compose` subcommand, superseding the earlier standalone Python-based `docker-compose` tool.
Overview
Docker Compose was created to address a common limitation of using the Docker CLI directly: running an application made of several containers, such as a web server, a database, and a cache, requires manually starting each container with correctly configured networking and volume flags. Compose lets a developer describe all of these services declaratively in a `compose.yaml` file, specifying image sources, environment variables, port mappings, and dependencies between services in one place. Mechanically, running `docker compose up` reads that file, builds any services with a defined build context, creates a shared network so containers can reach each other by service name rather than by IP address, and starts everything according to the file's configuration; `docker compose down` tears the whole set back down and removes the associated network. This makes it straightforward to reproduce a consistent local environment across a team, since the entire multi-container setup lives in a version-controlled file rather than a set of manual setup instructions in a wiki. Compose sits below full orchestration platforms in scope: it targets a single host by default, whereas Kubernetes or Docker Swarm coordinate containers across many hosts with scheduling, self-healing, and rolling updates. Docker later integrated Compose functionality directly into the Docker CLI as the `docker compose` subcommand, superseding the earlier standalone `docker-compose` Python-based tool, which simplified installation and kept the tool aligned with Docker Engine's own release cycle. In practice, Compose is most commonly used for local development and testing environments, where a developer runs the full application stack, including its database and supporting services, with one command instead of manually orchestrating several `docker run` invocations. Compose files can also define profiles to selectively start subsets of services, override files to layer environment-specific configuration on top of a base file, and health checks to control startup ordering more precisely than simple dependency declarations alone. While some teams historically used Compose for small-scale production deployments, orchestration platforms are generally used for production-grade multi-host container orchestration once an application outgrows a single machine. This flexibility has made Compose a common entry point for developers learning containerized application architecture before moving to full orchestration platforms. Developers moving an application from local Compose-based development toward production often translate the same service definitions into Kubernetes manifests or Swarm stack files by hand, since Compose's single-host model does not extend automatically to a distributed, self-healing multi-host deployment without that additional translation step. This extra translation step is one reason many teams eventually adopt Kubernetes-native tooling that can generate manifests from Compose files as a starting point rather than a finished migration.
Key Features
- Declarative YAML definition of multi-container application services
- Single-command startup and teardown of an entire application stack
- Automatic shared networking between services by name
- Volume and environment variable configuration per service
- Support for build contexts alongside prebuilt images
- Profiles for selectively starting subsets of services
- Override files for layering environment-specific configuration
- Integrated directly into the Docker CLI as `docker compose`
Use Cases
Alternatives
Frequently Asked Questions
From the Blog
Docker for Beginners: Containers Explained
Understand Docker from scratch: what containers are, images versus containers, Dockerfiles, volumes, networking, and Compose, explained in plain language.
Read More Cloud & CybersecurityDocker for Beginners: A Complete Guide
Docker packages an app with everything it needs into a container that runs identically anywhere. Learn images, containers, Dockerfiles, and core commands here.
Read More Cloud & CybersecurityDocker Compose for Beginners
Docker Compose runs multi-container apps from a single YAML file with one command. Learn how to define services, networks, and volumes for local development.
Read More Certifications & GuidesDocker Certified Associate Study Guide
The Docker Certified Associate validates real containerization skills. Here is what the exam covers, the core Docker concepts to master, and how to prepare.
Read More