docker/cli · error

other flags may not be combined with --rollback

Error message

other flags may not be combined with --rollback

What it means

Thrown by runUpdate (cli/command/service/update.go:180) when `--rollback` is combined with any other changed mutating flag. Only `--rollback`, `--detach`, and `--quiet` are exempt. Rollback restores the entire previous spec wholesale, so partial edits alongside it would be self-contradictory and are rejected up front.

Solutions

  1. Run rollback as its own command with no mutating flags: `docker service update --rollback <svc>`.
  2. Apply other changes in a separate subsequent `docker service update` call after the rollback converges.
  3. Audit wrapper scripts that blanket-append flags to every update invocation.

Example fix

// before
docker service update --rollback --env-add FOO=bar web

// after
docker service update --rollback web
docker service update --env-add FOO=bar web
Defensive patterns

Strategy: validation

Validate before calling

// Reject rollback+other-flags before calling the API.
rollback, _ := flags.GetBool(flagRollback)
if rollback {
	var extra []string
	flags.VisitAll(func(f *pflag.Flag) {
		if f.Name != flagRollback && f.Name != flagDetach && f.Name != flagQuiet && flags.Changed(f.Name) {
			extra = append(extra, f.Name)
		}
	})
	if len(extra) > 0 {
		return fmt.Errorf("--rollback must run alone; drop: %s", strings.Join(extra, ", "))
	}
}

Prevention

When it happens

Trigger: Invoking `docker service update --rollback <other-flag> <svc>` where the other flag's Changed bit is set, e.g. `docker service update --rollback --image nginx:alpine web`. The VisitAll loop sets otherFlagsPassed=true and the error fires.

Common situations: An operator tries to roll back and simultaneously tweak an option in one shot; a CI script concatenates a rollback with environment or image flags; alias/wrapper scripts always append extra flags.

Related errors


AI-assisted analysis of docker/cli@4f84911bfe (2026-08-07). Data as JSON: /api/errors/8ce01d32b97bfe5c. Report an issue: GitHub.

Appendix: source

Thrown at cli/command/service/update.go:180

	rollback, err := flags.GetBool(flagRollback)
	if err != nil {
		return err
	}

	if rollback {
		// Rollback can't be combined with other flags.
		otherFlagsPassed := false
		flags.VisitAll(func(f *pflag.Flag) {
			if f.Name == flagRollback || f.Name == flagDetach || f.Name == flagQuiet {
				return
			}
			if flags.Changed(f.Name) {
				otherFlagsPassed = true
			}
		})
		if otherFlagsPassed {
			return errors.New("other flags may not be combined with --rollback")
		}
	}

	updateOpts := client.ServiceUpdateOptions{}
	rollbackAction := "none"
	if rollback {
		rollbackAction = "previous"
	}

	spec := &res.Service.Spec
	err = updateService(ctx, apiClient, flags, spec)
	if err != nil {
		return err
	}

	if flags.Changed("image") {
		updateOpts.QueryRegistry = !options.noResolveImage
	}

View on GitHub (pinned to 4f84911bfe)