{"id":"e828697d8e5e6c21","repo":"docker/cli","slug":"failed-to-update-service-s-w","errorCode":null,"errorMessage":"failed to update service %s: %w","messagePattern":"failed to update service (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/stack/deploy_composefile.go","lineNumber":274,"sourceCode":"\t\t\tdefault:\n\t\t\t\tif image == svc.Spec.Labels[convert.LabelImage] {\n\t\t\t\t\t// image has not changed; update the serviceSpec with the\n\t\t\t\t\t// existing information that was set by QueryRegistry on the\n\t\t\t\t\t// previous deploy. Otherwise this will trigger an incorrect\n\t\t\t\t\t// service update.\n\t\t\t\t\tserviceSpec.TaskTemplate.ContainerSpec.Image = svc.Spec.TaskTemplate.ContainerSpec.Image\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Stack deploy does not have a `--force` option. Preserve existing\n\t\t\t// ForceUpdate value so that tasks are not re-deployed if not updated.\n\t\t\t// TODO move this to API client?\n\t\t\tserviceSpec.TaskTemplate.ForceUpdate = svc.Spec.TaskTemplate.ForceUpdate\n\n\t\t\tupdateOpts.Spec = serviceSpec\n\t\t\tresponse, err := apiClient.ServiceUpdate(ctx, svc.ID, updateOpts)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"failed to update service %s: %w\", name, err)\n\t\t\t}\n\n\t\t\tfor _, warning := range response.Warnings {\n\t\t\t\t_, _ = fmt.Fprintln(dockerCLI.Err(), warning)\n\t\t\t}\n\n\t\t\tserviceIDs = append(serviceIDs, svc.ID)\n\t\t} else {\n\t\t\t_, _ = fmt.Fprintln(out, \"Creating service\", name)\n\n\t\t\t// query registry if flag disabling it was not set\n\t\t\tqueryRegistry := resolveImage == resolveImageAlways || resolveImage == resolveImageChanged\n\n\t\t\tresponse, err := apiClient.ServiceCreate(ctx, client.ServiceCreateOptions{\n\t\t\t\tSpec:                serviceSpec,\n\t\t\t\tEncodedRegistryAuth: encodedAuth,\n\t\t\t\tQueryRegistry:       queryRegistry,\n\t\t\t})","sourceCodeStart":256,"sourceCodeEnd":292,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/cli/command/stack/deploy_composefile.go#L256-L292","documentation":"Error \"failed to update service %s: %w\" thrown in docker/cli.","triggerScenarios":"Thrown at cli/command/stack/deploy_composefile.go:274 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}