← All notes

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

This lets debugging or development services live in a single compose.yml file and be activated only as needed.

See also

Claims

Sources

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

Permanent ID: iil:note:ymyen8bg

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.},
}

Markdown

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.