{"id":"8ce01d32b97bfe5c","repo":"docker/cli","slug":"other-flags-may-not-be-combined-with-rollback","errorCode":null,"errorMessage":"other flags may not be combined with --rollback","messagePattern":"other flags may not be combined with --rollback","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/service/update.go","lineNumber":180,"sourceCode":"\n\trollback, err := flags.GetBool(flagRollback)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif rollback {\n\t\t// Rollback can't be combined with other flags.\n\t\totherFlagsPassed := false\n\t\tflags.VisitAll(func(f *pflag.Flag) {\n\t\t\tif f.Name == flagRollback || f.Name == flagDetach || f.Name == flagQuiet {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif flags.Changed(f.Name) {\n\t\t\t\totherFlagsPassed = true\n\t\t\t}\n\t\t})\n\t\tif otherFlagsPassed {\n\t\t\treturn errors.New(\"other flags may not be combined with --rollback\")\n\t\t}\n\t}\n\n\tupdateOpts := client.ServiceUpdateOptions{}\n\trollbackAction := \"none\"\n\tif rollback {\n\t\trollbackAction = \"previous\"\n\t}\n\n\tspec := &res.Service.Spec\n\terr = updateService(ctx, apiClient, flags, spec)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif flags.Changed(\"image\") {\n\t\tupdateOpts.QueryRegistry = !options.noResolveImage\n\t}","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/cli/command/service/update.go#L162-L198","documentation":"Emitted by `docker service update --rollback`. At update.go:168-181 the CLI walks every changed flag; only --rollback, --detach and --quiet are allowed alongside a rollback. Rollback restores the service's PreviousSpec verbatim, so combining it with spec-mutating flags (--image, --env-add, ...) would be contradictory — the CLI rejects it rather than silently ignoring the extra flags.","triggerScenarios":"`docker service update --rollback --image foo:v1 mysvc` or any invocation where flags.Changed() is true for a flag other than rollback/detach/quiet while --rollback is set.","commonSituations":"Trying to 'roll back and also fix' in one command; scripts that always append common flags (e.g. --with-registry-auth) to every update invocation including rollbacks; misunderstanding rollback as 'update to a specified older version'.","solutions":["Run the rollback alone: `docker service update --rollback <svc>` (optionally with --detach/--quiet)","If you want a specific older configuration rather than the previous spec, drop --rollback and specify the desired flags explicitly (e.g. --image foo:v1)","Split into two commands: rollback first, then a separate `docker service update` for further changes"],"exampleFix":"# before\ndocker service update --rollback --image myapp:1.0 web\n\n# after\ndocker service update --rollback web\n# or, to pin a specific version:\ndocker service update --image myapp:1.0 web","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":["swarm","service","update","rollback","flag-validation"],"analyzedSha":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}