docker/cli ยท error

context name %q is invalid, names are validated against rege

Error message

context name %q is invalid, names are validated against regexp %q

What it means

Error "context name %q is invalid, names are validated against regexp %q" thrown in docker/cli.

Source

Thrown at cli/context/store/store.go:224

// GetStorageInfo returns the paths where the Metadata and TLS data are stored
// for the context.
func (s *ContextStore) GetStorageInfo(contextName string) StorageInfo {
	return StorageInfo{
		MetadataPath: s.meta.contextDir(contextdirOf(contextName)),
		TLSPath:      s.tls.contextDir(contextName),
	}
}

// ValidateContextName checks a context name is valid.
func ValidateContextName(name string) error {
	if name == "" {
		return errors.New("context name cannot be empty")
	}
	if name == "default" {
		return errors.New(`"default" is a reserved context name`)
	}
	if !isValidName(name) {
		return fmt.Errorf("context name %q is invalid, names are validated against regexp %q", name, validNameFormat)
	}
	return nil
}

// validNameFormat is used as part of errors for invalid context-names.
// We should consider making this less technical ("must start with "a-z",
// and only consist of alphanumeric characters and separators").
const validNameFormat = `^[a-zA-Z0-9][a-zA-Z0-9_.+-]+$`

// isValidName checks if the context-name is valid ("^[a-zA-Z0-9][a-zA-Z0-9_.+-]+$").
//
// Names must start with an alphanumeric character (a-zA-Z0-9), followed by
// alphanumeric or separators ("_", ".", "+", "-").
func isValidName(s string) bool {
	if len(s) < 2 || !isAlphaNum(s[0]) {
		return false
	}

View on GitHub (pinned to e9452d6e78)

When it happens

Trigger: Thrown at cli/context/store/store.go:224 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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