Compose profiles keep optional services off until a profile is activated
Answer: Give a service a profiles: [debug] attribute and it only starts when that profile is active, via --profile debug or COMPOSE_PROFILES=debug. Services without a profiles attribute are always enabled.
Example
services:
frontend:
image: frontend
profiles: [frontend]
phpmyadmin:
image: phpmyadmin
depends_on: [db]
profiles: [debug]
backend:
image: backend
db:
image: mysql
Here plain docker compose up would only start backend and db. The frontend and phpmyadmin services are only started when their respective profiles are enabled.
Activating profiles
docker compose --profile debug up
docker compose --profile frontend --profile debug up
COMPOSE_PROFILES=frontend,debug docker compose up
docker compose --profile "*" up
Rules worth knowing
- Services can be assigned to one or more profiles.
- A service is ignored when none of its listed profiles match the active ones, unless the service is explicitly targeted by a command. Then its profile is added to the set of active profiles, which is useful for running one-off services or debugging tools.
- Other top-level elements are not affected by profiles.
This lets debugging or development services live in a single compose.yml file and be activated only as needed.
See also
Claims
- id: C1 claim: Services without a profiles attribute are always enabled. source: S1 evidence: "Services without a profiles attribute are always enabled."
- id: C2 claim: Explicitly targeting a service runs it regardless of its profile. source: S1 evidence: "Compose runs that service regardless of whether its profile is activated"
- id: C3 claim: A service is ignored when none of its profiles are active. source: S2 evidence: "ignored by Compose when none of the listed profiles match the active ones"
- id: C4 claim: Profiles are defined with a services-level profiles attribute. source: S2 evidence: "The services top-level element supports a profiles attribute"
Sources
- [S1] Using profiles with Compose. Docker docs (Compose how-tos). https://docs.docker.com/compose/how-tos/profiles/ . License: Apache-2.0. Accessed 2026-11-18.
- [S2] Profiles (Compose file reference). Docker docs (reference). https://docs.docker.com/reference/compose-file/profiles/ . License: Apache-2.0. Accessed 2026-11-18.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Docker docs (Compose how-tos), Using profiles with Compose; Docker docs (reference), Profiles (Compose file reference). Apache-2.0 (https://raw.githubusercontent.com/docker/docs/main/LICENSE). Copyright Docker, Inc. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Docker docs (Compose how-tos), Using profiles with Compose; Docker docs (reference), Profiles (Compose file reference). Apache-2.0 (https://raw.githubusercontent.com/docker/docs/main/LICENSE). Copyright Docker, Inc.
Cite this
iinventedlight. 2026. "Compose profiles keep optional services off until a profile is activated." iinventedlight Library, iil:note:ymyen8bg, version of 2026-11-18. https://iinventedlight.com/library/notes/docker-compose-profiles/. License: CC-BY-4.0.
@misc{iil_note_ymyen8bg,
author = {{iinventedlight}},
title = {{Compose profiles keep optional services off until a profile is activated}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-18},
url = {https://iinventedlight.com/library/notes/docker-compose-profiles/},
note = {Permanent ID iil:note:ymyen8bg. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/docker-compose-profiles.md.