docker/cli ยท error

test and disable can't be set at the same time

Error message

test and disable can't be set at the same time

What it means

Raised by convertHealthcheck in the compose-to-swarm converter when a service's healthcheck sets `disable: true` while also providing a `test` command. Disabling means the converter emits Test: ["NONE"], which contradicts an explicit test, so the ambiguous config is rejected rather than silently picking one.

Source

Thrown at cli/compose/convert/service.go:443

		if hostName, ipAddr, ok := strings.Cut(hostIP, ":"); ok {
			// Convert to SwarmKit notation: IP-address hostname(s)
			hosts = append(hosts, ipAddr+" "+hostName)
		}
	}
	return hosts
}

func convertHealthcheck(healthcheck *composetypes.HealthCheckConfig) (*container.HealthConfig, error) {
	if healthcheck == nil {
		return nil, nil
	}
	var (
		timeout, interval, startPeriod, startInterval time.Duration
		retries                                       int
	)
	if healthcheck.Disable {
		if len(healthcheck.Test) != 0 {
			return nil, errors.New("test and disable can't be set at the same time")
		}
		return &container.HealthConfig{
			Test: []string{"NONE"},
		}, nil
	}
	if healthcheck.Timeout != nil {
		timeout = time.Duration(*healthcheck.Timeout)
	}
	if healthcheck.Interval != nil {
		interval = time.Duration(*healthcheck.Interval)
	}
	if healthcheck.StartPeriod != nil {
		startPeriod = time.Duration(*healthcheck.StartPeriod)
	}
	if healthcheck.StartInterval != nil {
		startInterval = time.Duration(*healthcheck.StartInterval)
	}
	if healthcheck.Retries != nil {

View on GitHub (pinned to e9452d6e78)

Solutions

  1. Remove the `test:` entry (or the whole healthcheck block except `disable: true`) if you want the check disabled
  2. Remove `disable: true` if you want the healthcheck to run
  3. Check merged config with `docker compose config` to find which override file injects the conflicting key

Example fix

# before
healthcheck:
  disable: true
  test: ["CMD", "curl", "-f", "http://localhost/"]
# after
healthcheck:
  disable: true

When it happens

Trigger: Deploying with `docker stack deploy` a compose file where a service has `healthcheck: {disable: true, test: [...]}`. Any non-empty Test list combined with Disable triggers it during conversion, before the service is created.

Common situations: Temporarily disabling a healthcheck by adding `disable: true` without removing/commenting the existing `test`; merged/override compose files (docker-compose.yml + override) where one file sets test and another sets disable; copy-paste from examples.

Related errors


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