Member-only story
How Compose works
Docker Compose relies on a YAML configuration file, usually named compose.yaml
.
The compose.yaml
file follows the rules provided by the Compose Specification in how to define multi-container applications.
👉 Compose Specification:
The Compose Specification is the latest and recommended version of the Compose file format. It helps you define a Compose file which is used to configure your Docker application’s services, networks, volumes, and more.
Legacy versions 2.x and 3.x of the Compose file format were merged into the Compose Specification. It is implemented in versions 1.27.0 and above (also known as Compose V2) of the Docker Compose CLI.
👉 The Compose file
The default path for a Compose file is compose.yaml
(preferred) or compose.yml
that is placed in the working directory. Compose also supports docker-compose.yaml
and docker-compose.yml
for backwards compatibility of earlier versions. If both files exist, Compose prefers the canonical compose.yaml
.
Multiple Compose files can be merged together to define the application model. The combination of YAML files is implemented by appending or overriding YAML elements based on the Compose file order you set. Simple attributes and maps get overridden by the highest order Compose file, lists get merged by…