{"record":{"id":"c03b0cceb6ba5648","repo":"docker/compose","slug":"detach-cannot-be-combined-with-abort-on-contai","errorCode":null,"errorMessage":"--detach cannot be combined with --abort-on-container-exit, --abort-on-container-failure, --attach, --attach-dependencies or --watch","messagePattern":"--detach 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":213,"sourceCode":"\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}\n\n//nolint:gocyclo","sourceCodeStart":195,"sourceCodeEnd":231,"githubUrl":"https://github.com/docker/compose/blob/ddc4b044b62e9f715212ea4143fa830fac76382f/cmd/compose/up.go#L195-L231","documentation":"Returned by validateFlags when the user explicitly passes --detach (-d) together with any of --attach-dependencies, --abort-on-container-exit, --abort-on-container-failure, --attach SERVICE, or --watch. All of those flags require foreground mode to stream output or observe container exits; the '--detach' variant of the message is used because --wait was not what set Detach. This is the mirror of the --wait variant at up.go:211.","triggerScenarios":"`docker compose up -d --attach web`; `up -d --watch`; `up -d --abort-on-container-exit`; `up --detach --attach-dependencies`. Shell aliases like `alias cup='docker compose up -d'` then appending --watch manually.","commonSituations":"A 'detached by default' alias or COMPOSE_FILE wrapper where users add watch/attach flags; CI scripts that always pass -d and later gain abort/exit-code flags for failure propagation.","solutions":["Run foreground for attach/watch semantics: drop -d/--detach.","Keep -d and get logs/exit behavior another way: `up -d` then `docker compose logs -f` or `docker compose wait`.","Remove -d from aliases/wrappers when the command line already contains attach/abort/watch flags."],"exampleFix":"# before\ndocker compose up -d --attach web\n\n# after\ndocker compose up --attach web   # foreground\n# or detached alternative:\ndocker compose up -d && docker compose logs -f web","handlingStrategy":"validation","validationCode":"if [[ \"$UP_FLAGS\" == *-d* || \"$UP_FLAGS\" == *--detach* ]]; then\n  for f in --attach --attach-dependencies --abort-on-container-exit --abort-on-container-failure --watch; do\n    [[ \"$UP_FLAGS\" == *\"$f\"* ]] && { echo \"--detach conflicts with $f\" >&2; exit 2; }\n  done\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Avoid blanket '-d' aliases that later get attach/watch flags appended.","For detached monitoring use logs -f or docker compose ps polling."],"tags":["cli","up","flags","validation","detach","attach","watch","compose"],"backgroundTag":null,"analyzedSha":"ddc4b044b62e9f715212ea4143fa830fac76382f","analyzedAt":"2026-08-15T13:31:42.319Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}