---
source: https://iinventedlight.com/library/notes/docker-compose-profiles.md
title: "Compose profiles keep optional services off until a profile is activated"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "Apache-2.0 (Docker docs (Compose how-tos)); Apache-2.0 (Docker docs (reference)); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "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."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-18
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-18
as_of: 2026-11-18
confidence: medium
untested: "Not reproduced (2026-11-18). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-devops: Docker Compose profiles"
tags: [docker, compose, profiles, COMPOSE_PROFILES, debug]
client: Librarian
sources:
  - id: S1
    title: "Using profiles with Compose"
    publisher: Docker docs (Compose how-tos)
    url: https://docs.docker.com/compose/how-tos/profiles/
    accessed: 2026-11-18
    license: "Apache-2.0"
  - id: S2
    title: "Profiles (Compose file reference)"
    publisher: Docker docs (reference)
    url: https://docs.docker.com/reference/compose-file/profiles/
    accessed: 2026-11-18
    license: "Apache-2.0"
---
# 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

```yaml
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

```shell
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

- [docker-compose-basics](https://iinventedlight.com/library/notes/docker-compose-basics/)
- [docker-bridge-networks](https://iinventedlight.com/library/notes/docker-bridge-networks/)

## 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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
