{"record":{"id":"10f11c57f94102cc","repo":"docker/cli","slug":"default-is-a-reserved-context-name","errorCode":null,"errorMessage":"\"default\" is a reserved context name","messagePattern":"\"default\" is a reserved context name","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/context/store/store.go","lineNumber":221,"sourceCode":"\treturn s.tls.getData(contextName, endpointName, fileName)\n}\n\n// GetStorageInfo returns the paths where the Metadata and TLS data are stored\n// for the context.\nfunc (s *ContextStore) GetStorageInfo(contextName string) StorageInfo {\n\treturn StorageInfo{\n\t\tMetadataPath: s.meta.contextDir(contextdirOf(contextName)),\n\t\tTLSPath:      s.tls.contextDir(contextName),\n\t}\n}\n\n// ValidateContextName checks a context name is valid.\nfunc ValidateContextName(name string) error {\n\tif name == \"\" {\n\t\treturn errors.New(\"context name cannot be empty\")\n\t}\n\tif name == \"default\" {\n\t\treturn errors.New(`\"default\" is a reserved context name`)\n\t}\n\tif !isValidName(name) {\n\t\treturn fmt.Errorf(\"context name %q is invalid, names are validated against regexp %q\", name, validNameFormat)\n\t}\n\treturn nil\n}\n\n// validNameFormat is used as part of errors for invalid context-names.\n// We should consider making this less technical (\"must start with \"a-z\",\n// and only consist of alphanumeric characters and separators\").\nconst validNameFormat = `^[a-zA-Z0-9][a-zA-Z0-9_.+-]+$`\n\n// isValidName checks if the context-name is valid (\"^[a-zA-Z0-9][a-zA-Z0-9_.+-]+$\").\n//\n// Names must start with an alphanumeric character (a-zA-Z0-9), followed by\n// alphanumeric or separators (\"_\", \".\", \"+\", \"-\").\nfunc isValidName(s string) bool {\n\tif len(s) < 2 || !isAlphaNum(s[0]) {","sourceCodeStart":203,"sourceCodeEnd":239,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/context/store/store.go#L203-L239","documentation":"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.","triggerScenarios":"Running 'docker context create default ...' or calling ValidateContextName(\"default\"). The name is checked literally before the regex validation.","commonSituations":"A user attempts to recreate or redefine the default context. Automation that names contexts generically as 'default'.","solutions":["Choose a different name for the new context (e.g. 'default-remote', 'local').","To change the default behavior, set DOCKER_HOST and related env vars rather than creating a context named 'default'.","If you want to switch the active context, use 'docker context use <name>' on an existing non-reserved context."],"exampleFix":"# before\ndocker context create default --docker host=ssh://user@host\n# after\ndocker context create default-remote --docker host=ssh://user@host","handlingStrategy":"validation","validationCode":"if name == \"default\" {\n    return errors.New(\"'default' is reserved; choose another name\")\n}","typeGuard":"func isNonReservedName(s string) bool { return s != \"default\" && s != \"\" }","tryCatchPattern":null,"preventionTips":["Avoid naming user contexts 'default'.","Use descriptive names like 'prod-remote'.","To change defaults, set DOCKER_HOST instead."],"tags":["context","validation","naming","reserved"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}