{"id":"3a4421f307d70dac","repo":"docker/cli","slug":"health-start-period-cannot-be-negative","errorCode":null,"errorMessage":"--health-start-period cannot be negative","messagePattern":"--health-start-period cannot be negative","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/container/opts.go","lineNumber":588,"sourceCode":"\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,\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{","sourceCodeStart":570,"sourceCodeEnd":606,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/cli/command/container/opts.go#L570-L606","documentation":"--health-start-period is the grace window after container start during which failing probes don't count against the retry budget; the CLI rejects negative durations (opts.go:587-589). 0 means 'daemon default', so a negative grace period is invalid and caught client-side.","triggerScenarios":"`docker run --health-cmd '...' --health-start-period=-30s image` on run/create; any health flag set together with a negative start-period duration.","commonSituations":"Script-computed startup grace periods going negative; assuming -1 disables the start period (just omit it instead); unit/typo mistakes in compose-to-CLI translation.","solutions":["Use a positive grace period, e.g. --health-start-period=30s","Omit the flag or pass 0 to use the default (no extra grace period)","Fix the templating/arithmetic that produced a negative duration"],"exampleFix":"# before\ndocker run --health-cmd 'curl -f localhost' --health-start-period=-30s myimage\n# after\ndocker run --health-cmd 'curl -f localhost' --health-start-period=30s 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}