docker/compose · error

--always-recreate-deps and --no-recreate are incompatible

Error message

--always-recreate-deps and --no-recreate are incompatible

What it means

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.

Source

Thrown at cmd/compose/up.go:223

	}
	if create.Build && create.noBuild {
		return fmt.Errorf("--build and --no-build are incompatible")
	}
	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 {

View on GitHub (pinned to ddc4b044b6)

Solutions

  1. Drop --no-recreate when dependency recreation must happen.
  2. Or drop --always-recreate-deps and accept Compose's default (deps recreated only when their config changed).
  3. Use targeted commands instead: recreate dependencies explicitly with `docker compose up -d --force-recreate depname`.

Example fix

# before
docker compose up --always-recreate-deps --no-recreate

# after
docker compose up --always-recreate-deps
Defensive patterns

Strategy: validation

Validate before calling

if [[ "$UP_FLAGS" == *--always-recreate-deps* && "$UP_FLAGS" == *--no-recreate* ]]; then
  echo 'always-recreate-deps conflicts with no-recreate' >&2; exit 2
fi

Prevention

When it happens

Trigger: `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.

Common situations: 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.

Related errors


AI-assisted analysis of docker/compose@ddc4b044b6 (2026-08-15). Data as JSON: /api/errors/d6787b81588e7ab0. Report an issue: GitHub.