{"id":"d1c836994f04d2e6","repo":"docker/cli","slug":"default-context-cannot-be-created-nor-updated","errorCode":null,"errorMessage":"default context cannot be created nor updated","messagePattern":"default context cannot be created nor updated","errorType":"validation","errorClass":"invalidParameter","httpStatus":null,"severity":"error","filePath":"cli/command/defaultcontextstore.go","lineNumber":121,"sourceCode":"}\n\n// List implements store.Store's List\nfunc (s *ContextStoreWithDefault) List() ([]store.Metadata, error) {\n\tcontextList, err := s.Store.List()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefaultContext, err := s.Resolver()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn append(contextList, defaultContext.Meta), nil\n}\n\n// CreateOrUpdate is not allowed for the default context and fails\nfunc (s *ContextStoreWithDefault) CreateOrUpdate(meta store.Metadata) error {\n\tif meta.Name == DefaultContextName {\n\t\treturn invalidParameter(errors.New(\"default context cannot be created nor updated\"))\n\t}\n\treturn s.Store.CreateOrUpdate(meta)\n}\n\n// Remove is not allowed for the default context and fails\nfunc (s *ContextStoreWithDefault) Remove(name string) error {\n\tif name == DefaultContextName {\n\t\treturn invalidParameter(errors.New(\"default context cannot be removed\"))\n\t}\n\treturn s.Store.Remove(name)\n}\n\n// GetMetadata implements store.Store's GetMetadata\nfunc (s *ContextStoreWithDefault) GetMetadata(name string) (store.Metadata, error) {\n\tif name == DefaultContextName {\n\t\tdefaultContext, err := s.Resolver()\n\t\tif err != nil {\n\t\t\treturn store.Metadata{}, err","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/cli/command/defaultcontextstore.go#L103-L139","documentation":"ContextStoreWithDefault wraps the on-disk context store and injects the virtual 'default' context, whose settings come from environment variables and CLI flags rather than stored files. Its CreateOrUpdate override rejects any write where meta.Name == 'default' with an invalid-parameter error, since there is no backing storage for the default context and writes to it would be silently meaningless.","triggerScenarios":"Any code path calling ContextStoreWithDefault.CreateOrUpdate with Metadata.Name == \"default\" (cli/command/defaultcontextstore.go:119-121) — e.g. `docker context create default --docker ...`, `docker context update default ...`, `docker context import default file.tar`, or library code writing through the CLI's context store.","commonSituations":"Trying to change the default context's endpoint with `docker context update default` (the right lever is DOCKER_HOST or a new context); importing an exported context under the name 'default'; automation that regenerates contexts and includes the default in its write set.","solutions":["Create a differently-named context and switch to it: `docker context create mydefault --docker \"host=...\" && docker context use mydefault`.","To alter the default context's endpoint, set DOCKER_HOST (and DOCKER_TLS_VERIFY/DOCKER_CERT_PATH) in the environment instead of writing to the store.","When importing, pick another name: `docker context import restored ctx.tar`."],"exampleFix":"# before\ndocker context update default --docker \"host=ssh://user@host\"\n# after\ndocker context create remote --docker \"host=ssh://user@host\"\ndocker context use remote","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":["docker-cli","context","default-context","store"],"analyzedSha":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}