docker/cli · error

"default" is a reserved context name

Error message

"default" is a reserved context name

What it means

Returned by ValidateContextName when the name equals 'default'. The 'default' context is reserved for the built-in context derived from DOCKER_HOST and environment, so user-created contexts cannot use that name to avoid shadowing or confusing the reserved one.

Solutions

  1. Choose a different name for the new context (e.g. 'default-remote', 'local').
  2. To change the default behavior, set DOCKER_HOST and related env vars rather than creating a context named 'default'.
  3. If you want to switch the active context, use 'docker context use <name>' on an existing non-reserved context.

Example fix

# before
docker context create default --docker host=ssh://user@host
# after
docker context create default-remote --docker host=ssh://user@host
Defensive patterns

Strategy: validation

Validate before calling

if name == "default" {
    return errors.New("'default' is reserved; choose another name")
}

Type guard

func isNonReservedName(s string) bool { return s != "default" && s != "" }

Prevention

When it happens

Trigger: Running 'docker context create default ...' or calling ValidateContextName("default"). The name is checked literally before the regex validation.

Common situations: A user attempts to recreate or redefine the default context. Automation that names contexts generically as 'default'.

Related errors


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

Appendix: source

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

	return s.tls.getData(contextName, endpointName, fileName)
}

// 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]) {

View on GitHub (pinned to 4f84911bfe)