docker/compose · error

--no-recreate and --renew-anon-volumes are incompatible

Error message

--no-recreate and --renew-anon-volumes are incompatible

What it means

Returned by validateFlags when create.noInherit and create.noRecreate are both set. The message names --renew-anon-volumes, which is the user-facing flag that historically maps to the noInherit option (recreating anonymous volumes means not inheriting the previous container's volumes). Renewing anonymous volumes requires recreating the container, so combining it with --no-recreate (which forbids recreation) is contradictory and rejected.

Source

Thrown at cmd/compose/up.go:217

	}
	if up.wait {
		if up.attachDependencies || up.cascadeStop || len(up.attach) > 0 {
			return fmt.Errorf("--wait cannot be combined with --abort-on-container-exit, --attach or --attach-dependencies")
		}
		up.Detach = true
	}
	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,

View on GitHub (pinned to ddc4b044b6)

Solutions

  1. Drop --no-recreate when you need fresh anonymous volumes (renewal requires recreation).
  2. Or drop --renew-anon-volumes and accept inherited anonymous volume data.
  3. Consider named volumes for data you manage explicitly, making this flag pair unnecessary.

Example fix

# before
docker compose up --no-recreate --renew-anon-volumes

# after
docker compose up --renew-anon-volumes
Defensive patterns

Strategy: validation

Validate before calling

if [[ "$UP_FLAGS" == *--no-recreate* && "$UP_FLAGS" == *--renew-anon-volumes* ]]; then
  echo 'renew-anon-volumes requires recreation; drop --no-recreate' >&2; exit 2
fi

Prevention

When it happens

Trigger: `docker compose up --no-recreate --renew-anon-volumes`; the same combination via `docker compose create`/`run` paths that share createOptions and call validateFlags. Scripts that always pass --renew-anon-volumes to avoid stale data colliding with a --no-recreate added to preserve running containers.

Common situations: Teams pinning --no-recreate to keep containers alive during config-only changes, then adding --renew-anon-volumes to fix stale database data; long Makefile targets accumulating both flags across refactors.

Related errors


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