{"record":{"id":"d6787b81588e7ab0","repo":"docker/compose","slug":"always-recreate-deps-and-no-recreate-are-incom","errorCode":null,"errorMessage":"--always-recreate-deps and --no-recreate are incompatible","messagePattern":"--always-recreate-deps and --no-recreate are incompatible","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/compose/up.go","lineNumber":223,"sourceCode":"\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\nfunc runUp(\n\tctx context.Context,\n\tdockerCli command.Cli,\n\tbackendOptions *BackendOptions,\n\tcreateOptions createOptions,\n\tupOptions upOptions,\n\tbuildOptions buildOptions,\n\tproject *types.Project,\n\tservices []string,\n) error {","sourceCodeStart":205,"sourceCodeEnd":241,"githubUrl":"https://github.com/docker/compose/blob/ddc4b044b62e9f715212ea4143fa830fac76382f/cmd/compose/up.go#L205-L241","documentation":"Returned by validateFlags when create.recreateDeps (--always-recreate-deps) and create.noRecreate (--no-recreate) are both set. --always-recreate-deps forces recreation of dependent service containers; --no-recreate forbids recreating the primary containers. Since recreating dependencies while guaranteeing the dependents stay untouched is contradictory at the recreate-policy level, Compose rejects the pair up front.","triggerScenarios":"`docker compose up --always-recreate-deps --no-recreate`; the pair arriving via shared createOptions in `create`/`up`; scripts protecting a service with --no-recreate while a base-image bump layer adds --always-recreate-deps.","commonSituations":"Multi-service stacks where a wrapper pins --no-recreate for stateful services and CI adds --always-recreate-deps to force dependency refresh; accumulated flag lists in task runners.","solutions":["Drop --no-recreate when dependency recreation must happen.","Or drop --always-recreate-deps and accept Compose's default (deps recreated only when their config changed).","Use targeted commands instead: recreate dependencies explicitly with `docker compose up -d --force-recreate depname`."],"exampleFix":"# before\ndocker compose up --always-recreate-deps --no-recreate\n\n# after\ndocker compose up --always-recreate-deps","handlingStrategy":"validation","validationCode":"if [[ \"$UP_FLAGS\" == *--always-recreate-deps* && \"$UP_FLAGS\" == *--no-recreate* ]]; then\n  echo 'always-recreate-deps conflicts with no-recreate' >&2; exit 2\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Recreate specific dependencies explicitly: up -d --force-recreate <svc>.","Rely on default dependency recreation on config change."],"tags":["cli","up","flags","validation","recreate","dependencies","compose"],"backgroundTag":null,"analyzedSha":"ddc4b044b62e9f715212ea4143fa830fac76382f","analyzedAt":"2026-08-15T13:31:42.319Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}