Nine services in one file, of which three were needed for a normal day, and up started all nine.
services:
php: {}
mysql: {}
mailpit:
profiles: [dev]
elasticsearch:
profiles: [search]
# docker compose up → php, mysql only
# docker compose --profile dev up
# COMPOSE_PROFILES=dev,search docker compose up
A service with no profile always starts, which makes the default the minimal stack and the extras opt-in — the right way round, and the opposite of how these files usually grow. The environment variable is what belongs in a developer’s shell profile, so the flag does not have to be typed. The one sharp edge is that a service in a profile can still be depended on by one that is not, and Compose will start it regardless, which is correct and briefly confusing.