{"record":{"id":"79b6e93003e10f63","repo":"docker/cli","slug":"health-start-interval-cannot-be-negative","errorCode":null,"errorMessage":"--health-start-interval cannot be negative","messagePattern":"--health-start-interval cannot be negative","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/container/opts.go","lineNumber":591,"sourceCode":"\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,\n\t\t\tStartPeriod:   copts.healthStartPeriod,\n\t\t\tStartInterval: copts.healthStartInterval,\n\t\t\tRetries:       copts.healthRetries,\n\t\t}\n\t}\n\n\tdeviceRequests := copts.gpus.Value()\n\tif len(cdiDeviceNames) > 0 {\n\t\tcdiDeviceRequest := container.DeviceRequest{\n\t\t\tDriver:    \"cdi\",\n\t\t\tDeviceIDs: cdiDeviceNames,\n\t\t}","sourceCodeStart":573,"sourceCodeEnd":609,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/command/container/opts.go#L573-L609","documentation":"Returned when --health-start-interval is set to a negative duration (opts.go:590-592). The flag is registered via flags.DurationVar with a version annotation of 1.44 (opts.go:269-270), the most recent addition to the healthcheck options. It controls the check interval during the start period; negative values are rejected within the haveHealthSettings branch.","triggerScenarios":"Running `docker run --health-start-interval=-2s ...` or any negative duration while health settings are present. Requires API version 1.44+ on the daemon.","commonSituations":"Typo'd minus sign; passing a negative because the start-period interval is new and semantics are unclear; daemon older than 1.44 that does not recognize the flag (pflag still parses it client-side, then the guard fires).","solutions":["Use a positive duration like --health-start-interval=5s.","Use 0 (or omit) to inherit the daemon default.","Confirm the daemon supports API 1.44 (`docker version`)."],"exampleFix":"// before\ndocker run --health-start-interval=-2s --health-cmd=/check.sh myimage\n// after\ndocker run --health-start-interval=2s --health-cmd=/check.sh myimage","handlingStrategy":"validation","validationCode":"if copts.healthStartInterval < 0 {\n    return errors.New(\"--health-start-interval cannot be negative\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Reject negative durations before invoking the CLI.","Use 0 for daemon default.","Verify daemon API >= 1.44 (`docker version`) since this is the newest health flag."],"tags":["docker-cli","healthcheck","duration","negative-value","validation","container-create","api-version"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}