If a folder holds both compose.yaml and compose.override.yaml, a plain docker compose up loads the two of them. The override file is merged on top of the main one.
That makes it a good home for things that only belong on one machine: a debug flag, a bind mount to your source code, an extra port. The main file stays clean and can go into git, and the override can stay out of it.
# compose.override.yaml
services:
web:
environment:
DEBUG: "1"
volumes:
- ./src:/app/src
Single values like DEBUG are replaced. Lists such as ports and volumes are added to what the main file has, so you end up with both sets.
To see what Compose really builds from the pair, I’d run:
docker compose config
The automatic loading stops the moment you pass -f. With docker compose -f compose.yaml up the override file is ignored, and you have to name it yourself as a second -f. That trips people up in scripts and CI jobs: the stack behaves differently there, and the override file is the reason. If an override should never be picked up by accident, give it another name and load it on purpose.
Further reading: Merge Compose files