{
  "slug": "docker-compose-supports-pre-start-service-lifecycle-hooks-3751bc8de970",
  "title": "Docker Compose supports pre_start service lifecycle hooks",
  "tools": [
    "docker-compose"
  ],
  "tags": [
    "agent"
  ],
  "introduced_at": "2026-07-02T09:22:07.000Z",
  "announced_at": "2026-07-02T09:22:07.000Z",
  "effective_at": null,
  "date_basis": "source-publication",
  "status": "unknown",
  "how": {
    "incantation": "When a service needs initialization before it starts, configure its `pre_start` hook. Run `docker compose up` to start the application; each hook step runs in an ephemeral container and a non-zero exit prevents the service from starting.",
    "examples": [
      "services:\n  app:\n    image: <service-image>\n    pre_start:\n      - command: <initialization-command>\n\ndocker compose up"
    ],
    "gotchas": [
      "Version: v5.3.0",
      "services.<service>.pre_start: Sequence of init-container steps that run before the service container starts.",
      "pre_start[].command: Command to run; optional if the image entrypoint already runs the intended command.",
      "pre_start[].image: Image for the ephemeral container; defaults to the parent service image.",
      "pre_start[].user: Command user; defaults to the image user, or the service command user if `image` is omitted.",
      "pre_start[].privileged: Whether the hook command runs with privileged access.",
      "pre_start[].working_dir: Hook working directory; defaults to the service command working directory.",
      "pre_start[].environment: Environment values for the hook; inherits the service command environment and can append or override values.",
      "pre_start[].per_replica: Set `false` to run once for the service before any replica starts.",
      "Prerequisite: Requires Docker Compose 5.3.0 or later.",
      "The hook runs once per service, only when no replica is already running."
    ]
  },
  "why_it_matters": "Run a service initialization hook before starting its containers in a Compose application.",
  "sources": [
    "https://github.com/docker/compose/releases/tag/v5.3.0",
    "https://github.com/docker/compose/pull/13862",
    "https://docs.docker.com/reference/compose-file/services/"
  ],
  "rank": 0.91045,
  "judge": {
    "publish": true,
    "judge_model": "codex-cli/gpt-6-luna+typesafe/jev-1.13.0",
    "prompt_version": "extract-v7+enrich-v2+judge-v2x3+jev-publish-v1"
  },
  "review_state": "approved",
  "provenance": {
    "run_id": "wave1-20261014",
    "verdict_id": "wave1-20261014:wave1-20261014-5edf6c61b5fab568-0:gate",
    "evidence_hash": "95d6dd0baaef5a35032cee33e3cd6ea3c25a99ff3c9710074385114b9bc8df31"
  },
  "review": {
    "draft_hash": "077d55daa691f3309ac0004ea0432c8940d9e5be3a01f2a189802854baf7efc7",
    "reviewer": "publication-gate",
    "reviewed_at": "2026-10-07T00:00:00.000Z",
    "decision": "wave1-20261014:gate",
    "reason": "2 of 3 judge runs approved with p_yes >= 0.9 (mean 0.91 >= 0.9; 2 needed) and Jev gave 0.61 (>= 0.6 needed)."
  }
}
