{"record":{"id":"0241c4b449bb96f5","repo":"docker/compose","slug":"no-build-and-watch-are-incompatible","errorCode":null,"errorMessage":"--no-build and --watch are incompatible","messagePattern":"--no-build and --watch are incompatible","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/compose/up.go","lineNumber":226,"sourceCode":"\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 {\n\tif err := checksForRemoteStack(ctx, dockerCli, project, buildOptions, createOptions.AssumeYes, []string{}); err != nil {\n\t\treturn err\n\t}","sourceCodeStart":208,"sourceCodeEnd":244,"githubUrl":"https://github.com/docker/compose/blob/ddc4b044b62e9f715212ea4143fa830fac76382f/cmd/compose/up.go#L208-L244","documentation":"Returned by validateFlags when create.noBuild (--no-build) and up.watch (--watch) are both set. Watch mode rebuilds images when source files change, which requires building; --no-build forbids building. The combination is contradictory and rejected during PreRunE.","triggerScenarios":"`docker compose up --no-build --watch`; the pair arriving via shared options in paths that call validateFlags; dev scripts adding --no-build to force registry images while a developer adds --watch for iteration.","commonSituations":"Dev environments where a script pins --no-build (use prebuilt images) but the developer wants watch-mode rebuilds; flag lists grown organically in package.json scripts.","solutions":["Drop --no-build when using watch: `docker compose watch` or `docker compose up --watch`.","Keep --no-build and remove --watch; follow logs instead if you only need output.","Ensure services meant to be watched define a `develop.watch` section so watch has something to act on."],"exampleFix":"# before\ndocker compose up --no-build --watch\n\n# after\ndocker compose up --watch","handlingStrategy":"validation","validationCode":"if [[ \"$UP_FLAGS\" == *--no-build* && \"$UP_FLAGS\" == *--watch* ]]; then\n  echo 'watch needs build; drop --no-build' >&2; exit 2\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Watch mode is for build-backed dev loops; prebuilt-image runs should not use it.","Define develop.watch in compose.yml for watched services."],"tags":["cli","up","flags","validation","watch","build","compose"],"backgroundTag":null,"analyzedSha":"ddc4b044b62e9f715212ea4143fa830fac76382f","analyzedAt":"2026-08-15T13:31:42.319Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}