Marks a service as optional unless its profile is enabled.

Section: Profiles and Overrides

Define optional profiles

yaml
yaml
services:
  app:
    image: myapp:latest
  mailhog:
    image: mailhog/mailhog
    profiles: ["dev-tools"]
Explanation

Great for dev-only tools like Mailhog, Adminer, or Jaeger.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Profiles and Overrides
Enable a profile
Starts the stack with a selected optional profile enabled.
OpenIn sheetbashsame section
Layer multiple compose files
Merges multiple Compose files in order.
OpenIn sheetbashsame section
Use production-specific files
Applies production overrides like replicas, image tags, and secrets.
OpenIn sheetbashsame section
Minimal web + db stack
Simple two-service stack with port publishing and environment variables.
OpenIn sheetyaml2 tag match
Environment as key/value map
Provide container environment values inline in YAML.
OpenIn sheetyaml2 tag match
Simple service dependency
Starts `db` before `web` in dependency order.
OpenIn sheetyaml2 tag match