docker/cli · error

: parsing

Error message

%s: parsing %q: %w

What it means

Thrown by parseBool when strconv.ParseBool fails and the error is a *strconv.NumError (the common path). It formats '<key>: parsing "<value>": <reason>'. Affected keys are mainly skip-tls-verify passed through the --docker flag during context creation.

Solutions

  1. Use a Go-accepted bool literal: true/false or 1/0
  2. For skip-tls-verify, use --docker skip-tls-verify=true (or =1)
  3. Remove whitespace/quotes around the value

Example fix

# before
docker context create ctx --docker host=tcp://h:2376,skip-tls-verify=yes
# after
docker context create ctx --docker host=tcp://h:2376,skip-tls-verify=true
Defensive patterns

Strategy: validation

Validate before calling

// Normalize bool values before passing them to --docker.
func parseBoolStrict(s string) (bool, error) {
    switch strings.ToLower(strings.TrimSpace(s)) {
    case "1", "true", "t":
        return true, nil
    case "0", "false", "f":
        return false, nil
    }
    return false, fmt.Errorf("invalid bool %q", s)
}

Prevention

When it happens

Trigger: Passing `--docker skip-tls-verify=foo` (or yes/maybe/1.0) to docker context create. strconv.ParseBool only accepts 1, t, T, TRUE, true, True, 0, f, F, FALSE, false, False.

Common situations: Using 'yes'/'no' instead of 'true'/'false'; using an integer other than 0/1; quoting or trailing whitespace; locale-induced values.

Related errors


AI-assisted analysis of docker/cli@4f84911bfe (2026-08-07). Data as JSON: /api/errors/0085e0d53477276f. Report an issue: GitHub.

Appendix: source

Thrown at cli/command/context/options.go:74

			description: "Path to TLS key file",
		},
		{
			name:        keySkipTLSVerify,
			description: "Skip TLS certificate validation",
		},
	}
)

func parseBool(config map[string]string, name string) (bool, error) {
	strVal, ok := config[name]
	if !ok {
		return false, nil
	}
	res, err := strconv.ParseBool(strVal)
	if err != nil {
		var nErr *strconv.NumError
		if errors.As(err, &nErr) {
			return res, fmt.Errorf("%s: parsing %q: %w", name, nErr.Num, nErr.Err)
		}
		return res, fmt.Errorf("%s: %w", name, err)
	}
	return res, nil
}

func validateConfig(config map[string]string, allowedKeys map[string]struct{}) error {
	var errs []error
	for k := range config {
		if _, ok := allowedKeys[k]; !ok {
			errs = append(errs, errors.New("unrecognized config key: "+k))
		}
	}
	return errors.Join(errs...)
}

func getDockerEndpoint(contextStore store.Reader, config map[string]string) (docker.Endpoint, error) {
	if err := validateConfig(config, allowedDockerConfigKeys); err != nil {

View on GitHub (pinned to 4f84911bfe)