docker compose –profile, and the nine services you rarely need

A service with no profile always starts, which makes the default stack minimal and everything else opt-in — the right way round, and the opposite of how these files grow.

services:
  php: {}
  mysql: {}

  mailpit:
    profiles: [dev]
  elasticsearch:
    profiles: [search]
  kibana:
    profiles: [search]

# COMPOSE_PROFILES=dev,search in a shell profile, so the
# flag never has to be typed

A service inside a profile can still be started implicitly when something outside one depends on it, which is correct and briefly confusing the first time it happens. The measurable outcome on this stack was start-up dropping from fifty seconds to eleven and memory from three gigabytes to nine hundred megabytes, which is the difference between a stack people leave running and one they keep stopping.