Docker & ContainersIX Β· Docker ComposeCompose architecture
Compose v2 architecture β the plugin, the project model
What you'll learn
- Explain the Compose v2 plugin architecture and where the CLI plugin lives
- Derive a project name the way Compose does, and override it deliberately
- Read the Compose labels the daemon stores on every managed object
- Recognise when two directories are silently driving the same stack
Prerequisites
None β start here.
Verified against Docker Engine 29.x Β· Docker Engine 28.x Β· Docker Compose 2.x Β· containerd 2.x Β· runc 1.2.x Β· BuildKit 0.20+ Β· Linux kernel 5.15+ Β· Ubuntu 24.04 LTS Β· Debian 12 (Bookworm) Β· 2026-08-12
Compose is a declarative format for multi-container applications. A
compose.yml file describes services, networks, volumes, configs and
secrets. The docker compose CLI applies that description to the local
daemon.
That is the whole of it, and the word to hold onto is applies. Compose has no runtime of its own. It reads YAML, works out the difference between what the file says and what the daemon already has, and issues the same API calls you would issue by hand. Everything surprising about Compose comes from how it decides which existing objects belong to your file.
Compose v2 is a CLI plugin
Compose v2 is a plugin (docker compose) shipped with the Docker CLI. It is
not a separate binary you install and it is not the Python docker-compose
of v1, which reached end of life in July 2023.
$ docker compose version && docker info --format '{{range .ClientInfo.Plugins}}{{.Name}} {{.Version}} {{.Path}}{{println}}{{end}}'Docker Compose version v2.35.1
buildx v0.23.0 /usr/libexec/docker/cli-plugins/docker-buildx
compose v2.35.1 /usr/libexec/docker/cli-plugins/docker-composeIllustrative output
Two practical consequences. First, docker-compose with a hyphen may still
exist on the host as a shim or a leftover v1 install, and the two can
disagree about project naming rules β always type the space. Second, because
Compose is a client-side plugin, DOCKER_HOST applies to it: pointing that
variable at a remote daemon or an SSH endpoint makes docker compose up
deploy there, which is either exactly what you wanted or the reason a stack
appeared on the wrong host.
The file format is governed by the Compose Specification, an open standard that other tools also implement.
The project model
A Compose project is a set of services plus a project name. That name is not decoration: it is the key Compose uses to find the containers, networks and volumes it already owns.
PROJECT=myapp
docker ps -a --filter "label=com.docker.compose.project=$PROJECT" \
--format 'table {{.Names}}\t{{.Label "com.docker.compose.service"}}\t{{.Status}}'
# Every project the daemon knows about, including ones with no file left
docker compose ls --allEach project gets its own network by default, named <project>_default, and
containers within a project resolve each other by service name through the
daemonβs embedded DNS resolver at 127.0.0.11.
What Compose does
- Creates networks, volumes, configs and secrets as declared.
- Creates and starts containers in dependency order.
- Reconciles the running stack against the file on each
up, replacing only the containers whose config hash changed. - Tears down the project with
down. - Merges override files, resolves
.envinterpolation, selects profiles, and scales services.
What Compose does not do
- Schedule across hosts. Compose is a single-host tool.
- Self-heal across host failure. Restart policies are per-container and the daemon has to be alive to apply them.
- Roll deployments.
upreplaces containers; it does not shift traffic. - Replace Kubernetes or Swarm. Those are orchestrators.
For multi-host deployments, Compose can be the front end (define the application) and an orchestrator the back end (run it). Tools like Kompose translate a Compose file into Kubernetes manifests.
Knowledge check
Knowledge check Β· 5 questions
Q1. A Compose file defines:
Q2. The top-level `version:` key is obsolete: Compose validates against the most recent schema no matter what value the field holds.
Q3. Compose is run with no -p flag, no COMPOSE_PROJECT_NAME and no top-level name: key, from /srv/customer-b/app. What project name does it use?
Q4. Which labels does Compose stamp on the containers it creates? Select all that apply.
Q5. You suspect a host is running the same stack twice under two project names. Which command answers that directly?
Passing score: 75%. Answers are checked in this browser.