{"record":{"id":"33ed72ed9b6aecd4","repo":"docker/cli","slug":"s-conflicts-with-health-options-33ed72","errorCode":null,"errorMessage":"--%s conflicts with --health-* options","messagePattern":"--(.+?) conflicts with --health-\\* options","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/service/update.go","lineNumber":1276,"sourceCode":"func updateHealthcheck(flags *pflag.FlagSet, containerSpec *swarm.ContainerSpec) error {\n\tif !anyChanged(flags, flagNoHealthcheck, flagHealthCmd, flagHealthInterval, flagHealthRetries, flagHealthTimeout, flagHealthStartPeriod) {\n\t\treturn nil\n\t}\n\tif containerSpec.Healthcheck == nil {\n\t\tcontainerSpec.Healthcheck = &container.HealthConfig{}\n\t}\n\tnoHealthcheck, err := flags.GetBool(flagNoHealthcheck)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif noHealthcheck {\n\t\tif !anyChanged(flags, flagHealthCmd, flagHealthInterval, flagHealthRetries, flagHealthTimeout, flagHealthStartPeriod) {\n\t\t\tcontainerSpec.Healthcheck = &container.HealthConfig{\n\t\t\t\tTest: []string{\"NONE\"},\n\t\t\t}\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"--%s conflicts with --health-* options\", flagNoHealthcheck)\n\t}\n\tif len(containerSpec.Healthcheck.Test) > 0 && containerSpec.Healthcheck.Test[0] == \"NONE\" {\n\t\tcontainerSpec.Healthcheck.Test = nil\n\t}\n\tif flags.Changed(flagHealthInterval) {\n\t\tval := *flags.Lookup(flagHealthInterval).Value.(*opts.PositiveDurationOpt).Value()\n\t\tcontainerSpec.Healthcheck.Interval = val\n\t}\n\tif flags.Changed(flagHealthTimeout) {\n\t\tval := *flags.Lookup(flagHealthTimeout).Value.(*opts.PositiveDurationOpt).Value()\n\t\tcontainerSpec.Healthcheck.Timeout = val\n\t}\n\tif flags.Changed(flagHealthStartPeriod) {\n\t\tval := *flags.Lookup(flagHealthStartPeriod).Value.(*opts.PositiveDurationOpt).Value()\n\t\tcontainerSpec.Healthcheck.StartPeriod = val\n\t}\n\tif flags.Changed(flagHealthRetries) {\n\t\tcontainerSpec.Healthcheck.Retries, _ = flags.GetInt(flagHealthRetries)","sourceCodeStart":1258,"sourceCodeEnd":1294,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/command/service/update.go#L1258-L1294","documentation":"Raised by docker service update when --no-healthcheck is combined with any --health-* flag (--health-cmd, --health-interval, --health-retries, --health-timeout, or --health-start-period). These options are mutually exclusive because --no-healthcheck disables the healthcheck entirely while the --health-* options configure one, so the resulting intent is contradictory.","triggerScenarios":"Calling `docker service update --no-healthcheck --health-cmd /bin/true <service>` (or any combination where both flagNoHealthcheck and at least one health-cmd/interval/retries/timeout/start-period flag are changed in the same invocation). The check at update.go:1270 fires inside updateHealthcheck when noHealthcheck is true and anyChanged(...) returns true for the health config flags.","commonSituations":"Copying a service update command from a runbook and leaving a stale --health-cmd while adding --no-healthcheck; scripting service updates with a flag matrix that doesn't exclude the two groups; migrating from a Dockerfile HEALTHCHECK to disabling it on the CLI while the old health flags are still templated in.","solutions":["Remove either --no-healthcheck or all --health-* flags so only one intent is expressed.","If you want to disable, keep only --no-healthcheck and drop --health-cmd/--health-interval/--health-retries/--health-timeout/--health-start-period.","If you want to reconfigure, drop --no-healthcheck and set the desired --health-* values.","Audit your automation/template that generates the update command to mutually exclude the two flag groups."],"exampleFix":"// before\ndocker service update --no-healthcheck --health-cmd /bin/true myservice\n// after\ndocker service update --no-healthcheck myservice","handlingStrategy":"validation","validationCode":"// Validate before building the update flag set\nfunc hasHealthConfigFlag(flags []string) bool {\n    set := map[string]struct{}{}\n    for _, f := range flags {\n        set[f] = struct{}{}\n    }\n    health := []string{\"--health-cmd\", \"--health-interval\", \"--health-retries\", \"--health-timeout\", \"--health-start-period\"}\n    _, noHealth := set[\"--no-healthcheck\"]\n    if !noHealth {\n        return false\n    }\n    for _, h := range health {\n        if _, ok := set[h]; ok {\n            return true // conflict\n        }\n    }\n    return false\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never emit both --no-healthcheck and any --health-* flag in the same command.","In automation, model the healthcheck as a single optional struct and emit either a 'disable' flag or a 'config' set, never both.","Unit-test the flag-generation code with both branches."],"tags":["docker","service-update","healthcheck","flag-conflict","swarm"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}