{"record":{"id":"784ec8aa2cd3e860","repo":"docker/compose","slug":"no-build-is-incompatible-with-watch-action-s-in","errorCode":null,"errorMessage":"--no-build is incompatible with watch action %s in service %s","messagePattern":"--no-build is incompatible with watch action (.+?) in service (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/compose/watch.go","lineNumber":224,"sourceCode":"\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tif service.Develop != nil {\n\t\t\tconfig = service.Develop\n\t\t}\n\n\t\tif config == nil {\n\t\t\tcontinue\n\t\t}\n\n\t\tfor _, trigger := range config.Watch {\n\t\t\tif trigger.Action == types.WatchActionRebuild {\n\t\t\t\tif service.Build == nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"can't watch service %q with action %s without a build context\", service.Name, types.WatchActionRebuild)\n\t\t\t\t}\n\t\t\t\tif options.Build == nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"--no-build is incompatible with watch action %s in service %s\", types.WatchActionRebuild, service.Name)\n\t\t\t\t}\n\t\t\t\t// set the service to always be built - watch triggers `Up()` when it receives a rebuild event\n\t\t\t\tservice.PullPolicy = types.PullPolicyBuild\n\t\t\t\tproject.Services[serviceName] = service\n\t\t\t}\n\t\t}\n\n\t\tfor _, trigger := range config.Watch {\n\t\t\tif isSync(trigger) && checkIfPathAlreadyBindMounted(trigger.Path, service.Volumes) {\n\t\t\t\tlogrus.Warnf(\"path '%s' also declared by a bind mount volume, this path won't be monitored!\\n\", trigger.Path)\n\t\t\t\tcontinue\n\t\t\t} else {\n\t\t\t\tshouldInitialSync := trigger.InitialSync\n\n\t\t\t\t// Check legacy extension attribute for backward compatibility\n\t\t\t\tif !shouldInitialSync {\n\t\t\t\t\tvar legacyInitialSync bool\n\t\t\t\t\tsuccess, err := trigger.Extensions.Get(\"x-initialSync\", &legacyInitialSync)","sourceCodeStart":206,"sourceCodeEnd":242,"githubUrl":"https://github.com/docker/compose/blob/ddc4b044b62e9f715212ea4143fa830fac76382f/pkg/compose/watch.go#L206-L242","documentation":"A rebuild watch trigger requires compose to be allowed to build. When watch is invoked with options.Build == nil (the --no-build flag), the incompatibility is detected while building watch rules and fails with this error naming the service.","triggerScenarios":"Running docker compose watch --no-build (or passing WatchOptions without Build) on a project where any selected service's develop.watch contains action: rebuild.","commonSituations":"CI or scripts reusing flags from up --no-build; users trying to prevent image builds during watch while keeping rebuild triggers; copy-pasted command lines.","solutions":["Drop --no-build from the watch invocation so rebuild triggers can build.","Or remove/replace the rebuild triggers in the develop.watch config of the named service with sync or sync+restart.","Scope the watch command to services without rebuild triggers if --no-build must stay."],"exampleFix":"# before\n$ docker compose watch --no-build\n# Error: --no-build is incompatible with watch action rebuild in service web\n\n# after\n$ docker compose watch","handlingStrategy":"validation","validationCode":"func watchOptionsConsistent(project *types.Project, hasBuildOpt bool) error {\n\tfor name, svc := range project.Services {\n\t\tif svc.Develop == nil { continue }\n\t\tfor _, t := range svc.Develop.Watch {\n\t\t\tif t.Action == types.WatchActionRebuild && !hasBuildOpt {\n\t\t\t\treturn fmt.Errorf(\"cannot use --no-build: service %q rebuilds on watch\", name)\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}","typeGuard":null,"tryCatchPattern":"if _, err := composeService.Watch(ctx, projectName, watchOpts); err != nil {\n    if strings.Contains(err.Error(), \"--no-build is incompatible\") {\n        // drop --no-build / unset the no-build option and retry\n    }\n    return err\n}","preventionTips":["Never combine --no-build with watch on projects using rebuild actions.","Keep watch invocations minimal (compose watch with no extra flags) in dev scripts.","Document which services rely on rebuild triggers so flag choices are explicit."],"tags":["compose","watch","no-build","flag-conflict"],"backgroundTag":null,"analyzedSha":"ddc4b044b62e9f715212ea4143fa830fac76382f","analyzedAt":"2026-08-15T13:31:42.319Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}