{"id":"1a45d9c1bdcd673d","repo":"docker/cli","slug":"health-interval-cannot-be-negative","errorCode":null,"errorMessage":"--health-interval cannot be negative","messagePattern":"--health-interval cannot be negative","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/container/opts.go","lineNumber":579,"sourceCode":"\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\")\n\t\t}\n\t\tif copts.healthStartInterval < 0 {\n\t\t\treturn nil, errors.New(\"--health-start-interval cannot be negative\")\n\t\t}\n\n\t\thealthConfig = &container.HealthConfig{\n\t\t\tTest:          probe,\n\t\t\tInterval:      copts.healthInterval,\n\t\t\tTimeout:       copts.healthTimeout,","sourceCodeStart":561,"sourceCodeEnd":597,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/cli/command/container/opts.go#L561-L597","documentation":"When health settings are provided, the CLI rejects a negative --health-interval before building the container.HealthConfig (opts.go:578-580). The interval is a Go time.Duration controlling how often the health probe runs; a negative duration is meaningless, and 0 is reserved to mean 'use the daemon default'.","triggerScenarios":"`docker run --health-cmd '...' --health-interval=-5s image` or any create/run where the parsed duration is negative, e.g. a templated value like --health-interval=${INTERVAL} expanding to a negative duration.","commonSituations":"Computed durations in scripts going negative; attempting to use -1 to mean 'disable' (use --no-healthcheck instead); unit typos producing negative values.","solutions":["Set a positive duration, e.g. --health-interval=30s","Omit the flag (or pass 0) to use the default interval","Use --no-healthcheck if the goal is to disable health probing"],"exampleFix":"# before\ndocker run --health-cmd 'curl -f localhost' --health-interval=-10s myimage\n# after\ndocker run --health-cmd 'curl -f localhost' --health-interval=10s myimage","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":["docker-cli","healthcheck","duration","flag-validation"],"analyzedSha":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}