docker/compose · error
--no-build and --watch are incompatible
Error message
--no-build and --watch are incompatible
What it means
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.
Source
Thrown at cmd/compose/up.go:226
}
if up.Detach && (up.attachDependencies || up.cascadeStop || up.cascadeFail || len(up.attach) > 0 || up.watch) {
if up.wait {
return fmt.Errorf("--wait cannot be combined with --abort-on-container-exit, --abort-on-container-failure, --attach, --attach-dependencies or --watch")
} else {
return fmt.Errorf("--detach cannot be combined with --abort-on-container-exit, --abort-on-container-failure, --attach, --attach-dependencies or --watch")
}
}
if create.noInherit && create.noRecreate {
return fmt.Errorf("--no-recreate and --renew-anon-volumes are incompatible")
}
if create.forceRecreate && create.noRecreate {
return fmt.Errorf("--force-recreate and --no-recreate are incompatible")
}
if create.recreateDeps && create.noRecreate {
return fmt.Errorf("--always-recreate-deps and --no-recreate are incompatible")
}
if create.noBuild && up.watch {
return fmt.Errorf("--no-build and --watch are incompatible")
}
return nil
}
//nolint:gocyclo
func runUp(
ctx context.Context,
dockerCli command.Cli,
backendOptions *BackendOptions,
createOptions createOptions,
upOptions upOptions,
buildOptions buildOptions,
project *types.Project,
services []string,
) error {
if err := checksForRemoteStack(ctx, dockerCli, project, buildOptions, createOptions.AssumeYes, []string{}); err != nil {
return err
}View on GitHub (pinned to ddc4b044b6)
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.
Example fix
# before docker compose up --no-build --watch # after docker compose up --watch
Defensive patterns
Strategy: validation
Validate before calling
if [[ "$UP_FLAGS" == *--no-build* && "$UP_FLAGS" == *--watch* ]]; then echo 'watch needs build; drop --no-build' >&2; exit 2 fi
Prevention
- Watch mode is for build-backed dev loops; prebuilt-image runs should not use it.
- Define develop.watch in compose.yml for watched services.
When it happens
Trigger: `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.
Common situations: 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.
Related errors
- --build and --no-build are incompatible
- --wait cannot be combined with --abort-on-container-exit, --
- --detach cannot be combined with --abort-on-container-exit,
- --wait-timeout must be a non-negative integer
- --abort-on-container-failure cannot be combined with --abort
AI-assisted analysis of docker/compose@ddc4b044b6 (2026-08-15).
Data as JSON: /api/errors/0241c4b449bb96f5.
Report an issue: GitHub.