docker/cli ยท error

--health-start-period cannot be negative

Error message

--health-start-period cannot be negative

What it means

--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.

Source

Thrown at cli/command/container/opts.go:588

			return nil, errors.New("--no-healthcheck conflicts with --health-* options")
		}
		healthConfig = &container.HealthConfig{Test: []string{"NONE"}}
	} else if haveHealthSettings {
		var probe []string
		if copts.healthCmd != "" {
			probe = []string{"CMD-SHELL", copts.healthCmd}
		}
		if copts.healthInterval < 0 {
			return nil, errors.New("--health-interval cannot be negative")
		}
		if copts.healthTimeout < 0 {
			return nil, errors.New("--health-timeout cannot be negative")
		}
		if copts.healthRetries < 0 {
			return nil, errors.New("--health-retries cannot be negative")
		}
		if copts.healthStartPeriod < 0 {
			return nil, errors.New("--health-start-period cannot be negative")
		}
		if copts.healthStartInterval < 0 {
			return nil, errors.New("--health-start-interval cannot be negative")
		}

		healthConfig = &container.HealthConfig{
			Test:          probe,
			Interval:      copts.healthInterval,
			Timeout:       copts.healthTimeout,
			StartPeriod:   copts.healthStartPeriod,
			StartInterval: copts.healthStartInterval,
			Retries:       copts.healthRetries,
		}
	}

	deviceRequests := copts.gpus.Value()
	if len(cdiDeviceNames) > 0 {
		cdiDeviceRequest := container.DeviceRequest{

View on GitHub (pinned to e9452d6e78)

Solutions

  1. Use a positive grace period, e.g. --health-start-period=30s
  2. Omit the flag or pass 0 to use the default (no extra grace period)
  3. Fix the templating/arithmetic that produced a negative duration

Example fix

# before
docker run --health-cmd 'curl -f localhost' --health-start-period=-30s myimage
# after
docker run --health-cmd 'curl -f localhost' --health-start-period=30s myimage

When it happens

Trigger: `docker run --health-cmd '...' --health-start-period=-30s image` on run/create; any health flag set together with a negative start-period duration.

Common situations: 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.

Related errors


AI-assisted analysis of docker/cli@e9452d6e78 (2026-08-01). Data as JSON: /data/errors/3a4421f307d70dac.json. Report an issue: GitHub.