{"record":{"id":"6eca8304cfff3750","repo":"docker/compose","slug":"wait-cannot-be-combined-with-abort-on-containe-6eca83","errorCode":null,"errorMessage":"--wait cannot be combined with --abort-on-container-exit, --abort-on-container-failure, --attach, --attach-dependencies or --watch","messagePattern":"--wait cannot be combined with --abort-on-container-exit, --abort-on-container-failure, --attach, --attach-dependencies or --watch","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/compose/up.go","lineNumber":211,"sourceCode":"\t}\n\tif up.exitCodeFrom != \"\" && !up.cascadeFail {\n\t\tup.cascadeStop = true\n\t}\n\tif up.cascadeStop && up.cascadeFail {\n\t\treturn fmt.Errorf(\"--abort-on-container-failure cannot be combined with --abort-on-container-exit\")\n\t}\n\tif up.wait {\n\t\tif up.attachDependencies || up.cascadeStop || len(up.attach) > 0 {\n\t\t\treturn fmt.Errorf(\"--wait cannot be combined with --abort-on-container-exit, --attach or --attach-dependencies\")\n\t\t}\n\t\tup.Detach = true\n\t}\n\tif create.Build && create.noBuild {\n\t\treturn fmt.Errorf(\"--build and --no-build are incompatible\")\n\t}\n\tif up.Detach && (up.attachDependencies || up.cascadeStop || up.cascadeFail || len(up.attach) > 0 || up.watch) {\n\t\tif up.wait {\n\t\t\treturn fmt.Errorf(\"--wait cannot be combined with --abort-on-container-exit, --abort-on-container-failure, --attach, --attach-dependencies or --watch\")\n\t\t} else {\n\t\t\treturn fmt.Errorf(\"--detach cannot be combined with --abort-on-container-exit, --abort-on-container-failure, --attach, --attach-dependencies or --watch\")\n\t\t}\n\t}\n\tif create.noInherit && create.noRecreate {\n\t\treturn fmt.Errorf(\"--no-recreate and --renew-anon-volumes are incompatible\")\n\t}\n\tif create.forceRecreate && create.noRecreate {\n\t\treturn fmt.Errorf(\"--force-recreate and --no-recreate are incompatible\")\n\t}\n\tif create.recreateDeps && create.noRecreate {\n\t\treturn fmt.Errorf(\"--always-recreate-deps and --no-recreate are incompatible\")\n\t}\n\tif create.noBuild && up.watch {\n\t\treturn fmt.Errorf(\"--no-build and --watch are incompatible\")\n\t}\n\treturn nil\n}","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/docker/compose/blob/ddc4b044b62e9f715212ea4143fa830fac76382f/cmd/compose/up.go#L193-L229","documentation":"Returned by validateFlags when detached mode is active (directly via --detach, or implicitly because --wait set up.Detach = true) AND one of the attach-family flags is set: --attach-dependencies, --abort-on-container-exit (cascadeStop), --abort-on-container-failure (cascadeFail), explicit --attach, or --watch. Attaching to output or cascading on container exit only makes sense in foreground mode, so the combination is rejected. The '--wait' variant of the message is used because --wait forced detach earlier in the same function.","triggerScenarios":"`docker compose up --wait --watch`; `up --wait --abort-on-container-failure` (wait sets Detach, then the Detach branch with wait=true fires); note the earlier line 202 check usually catches simpler --wait+attach combos first, so this branch is reached for combos like --wait --watch or --wait --abort-on-container-failure.","commonSituations":"Wanting health-based wait plus watch mode for dev; CI passing --wait with abort flags copied from another job; scripts defaulting to --wait and layering --watch for iteration.","solutions":["Split the behaviors: `docker compose up --wait` for readiness, then separately `docker compose watch` or `logs -f`.","Drop --wait if you need --watch/--attach/--abort flags and rely on their own semantics.","Use `up -d` plus `docker compose ps --wait`-style polling if you need detached + monitored behavior."],"exampleFix":"# before\ndocker compose up --wait --watch\n\n# after\ndocker compose up --wait\ndocker compose watch","handlingStrategy":"validation","validationCode":"if [[ \"$UP_FLAGS\" == *--wait* ]]; then\n  for f in --attach --attach-dependencies --abort-on-container-exit --abort-on-container-failure --watch; do\n    [[ \"$UP_FLAGS\" == *\"$f\"* ]] && { echo \"--wait conflicts with $f\" >&2; exit 2; }\n  done\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember --wait implies detach; anything attach-like conflicts.","Run watch as its own `docker compose watch` command.","Prefer healthchecks + --wait over exit-based flow in CI."],"tags":["cli","up","flags","validation","wait","watch","detach","compose"],"backgroundTag":null,"analyzedSha":"ddc4b044b62e9f715212ea4143fa830fac76382f","analyzedAt":"2026-08-15T13:31:42.319Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}