{"record":{"id":"3ccd24350d0832ce","repo":"docker/cli","slug":"no-healthcheck-conflicts-with-health-options","errorCode":null,"errorMessage":"--no-healthcheck conflicts with --health-* options","messagePattern":"--no-healthcheck conflicts with --health-\\* options","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/container/opts.go","lineNumber":570,"sourceCode":"\n\tsecurityOpts, maskedPaths, readonlyPaths := parseSystemPaths(securityOpts)\n\n\tstorageOpts, err := parseStorageOpts(copts.storageOpt.GetSlice())\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Healthcheck\n\tvar healthConfig *container.HealthConfig\n\thaveHealthSettings := copts.healthCmd != \"\" ||\n\t\tcopts.healthInterval != 0 ||\n\t\tcopts.healthTimeout != 0 ||\n\t\tcopts.healthStartPeriod != 0 ||\n\t\tcopts.healthRetries != 0 ||\n\t\tcopts.healthStartInterval != 0\n\tif copts.noHealthcheck {\n\t\tif haveHealthSettings {\n\t\t\treturn nil, errors.New(\"--no-healthcheck conflicts with --health-* options\")\n\t\t}\n\t\thealthConfig = &container.HealthConfig{Test: []string{\"NONE\"}}\n\t} else if haveHealthSettings {\n\t\tvar probe []string\n\t\tif copts.healthCmd != \"\" {\n\t\t\tprobe = []string{\"CMD-SHELL\", copts.healthCmd}\n\t\t}\n\t\tif copts.healthInterval < 0 {\n\t\t\treturn nil, errors.New(\"--health-interval cannot be negative\")\n\t\t}\n\t\tif copts.healthTimeout < 0 {\n\t\t\treturn nil, errors.New(\"--health-timeout cannot be negative\")\n\t\t}\n\t\tif copts.healthRetries < 0 {\n\t\t\treturn nil, errors.New(\"--health-retries cannot be negative\")\n\t\t}\n\t\tif copts.healthStartPeriod < 0 {\n\t\t\treturn nil, errors.New(\"--health-start-period cannot be negative\")","sourceCodeStart":552,"sourceCodeEnd":588,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/command/container/opts.go#L552-L588","documentation":"Returned when --no-healthcheck is combined with any non-zero --health-* option (opts.go:562-571). haveHealthSettings is true if any of healthCmd, healthInterval, healthTimeout, healthStartPeriod, healthRetries, or healthStartInterval is set. --no-healthcheck writes Test=[\"NONE\"] which semantically contradicts defining a probe, so the conflict is rejected at parse time.","triggerScenarios":"Running `docker run --no-healthcheck --health-cmd=... ...` or pairing --no-healthcheck with any --health-interval/--health-timeout/--health-retries/--health-start-period/--health-start-interval. Triggered when haveHealthSettings is true alongside copts.noHealthcheck.","commonSituations":"Copy-pasting a base image's HEALTHCHECK-disabling flags while also layering new health options; overriding an image HEALTHCHECK by passing both --no-healthcheck and a new --health-cmd by mistake; templating tools (compose, helm) emitting both blocks.","solutions":["Remove --no-healthcheck if you want to define a custom probe via --health-*.","Remove all --health-* flags if you want to disable the image's HEALTHCHECK via --no-healthcheck.","Audit compose files / CI templates for both blocks being emitted together."],"exampleFix":"// before\ndocker run --no-healthcheck --health-cmd=/check.sh myimage\n// after\ndocker run --health-cmd=/check.sh myimage","handlingStrategy":"validation","validationCode":"// Reject the --no-healthcheck + any --health-* combination up front.\nif copts.noHealthcheck {\n    if copts.healthCmd != \"\" || copts.healthInterval != 0 || copts.healthTimeout != 0 ||\n        copts.healthRetries != 0 || copts.healthStartPeriod != 0 || copts.healthStartInterval != 0 {\n        return errors.New(\"--no-healthcheck conflicts with --health-* options\")\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat --no-healthcheck and --health-* as mutually exclusive in templates.","Lint compose files for simultaneous healthcheck.disable and healthcheck.* keys.","When overriding an image HEALTHCHECK, set new --health-* and never add --no-healthcheck."],"tags":["docker-cli","healthcheck","conflicting-options","validation","container-create"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}