{"record":{"id":"c155ce7119b39955","repo":"docker/cli","slug":"unable-to-get-endpoint-from-context-q","errorCode":null,"errorMessage":"unable to get endpoint from context %q","messagePattern":"unable to get endpoint from context %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/context/options.go","lineNumber":103,"sourceCode":"\t\t\terrs = append(errs, errors.New(\"unrecognized config key: \"+k))\n\t\t}\n\t}\n\treturn errors.Join(errs...)\n}\n\nfunc getDockerEndpoint(contextStore store.Reader, config map[string]string) (docker.Endpoint, error) {\n\tif err := validateConfig(config, allowedDockerConfigKeys); err != nil {\n\t\treturn docker.Endpoint{}, err\n\t}\n\tif contextName, ok := config[keyFrom]; ok {\n\t\tmetadata, err := contextStore.GetMetadata(contextName)\n\t\tif err != nil {\n\t\t\treturn docker.Endpoint{}, err\n\t\t}\n\t\tif ep, ok := metadata.Endpoints[docker.DockerEndpoint].(docker.EndpointMeta); ok {\n\t\t\treturn docker.Endpoint{EndpointMeta: ep}, nil\n\t\t}\n\t\treturn docker.Endpoint{}, fmt.Errorf(\"unable to get endpoint from context %q\", contextName)\n\t}\n\ttlsData, err := context.TLSDataFromFiles(config[keyCA], config[keyCert], config[keyKey])\n\tif err != nil {\n\t\treturn docker.Endpoint{}, err\n\t}\n\tskipTLSVerify, err := parseBool(config, keySkipTLSVerify)\n\tif err != nil {\n\t\treturn docker.Endpoint{}, err\n\t}\n\tep := docker.Endpoint{\n\t\tEndpointMeta: docker.EndpointMeta{\n\t\t\tHost:          config[keyHost],\n\t\t\tSkipTLSVerify: skipTLSVerify,\n\t\t},\n\t\tTLSData: tlsData,\n\t}\n\t// try to resolve a docker client, validating the configuration\n\topts, err := ep.ClientOpts()","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/command/context/options.go#L85-L121","documentation":"Thrown by getDockerEndpoint when a context-creation/update uses the 'from=<name>' option to copy another context's Docker endpoint, but the referenced context's Docker endpoint metadata is either absent or not of the expected docker.EndpointMeta type. The type assertion at options.go:100 fails, meaning the source context exists but has no valid Docker endpoint to copy from. This is a configuration-shape mismatch, not a missing-context error (that surfaces earlier at GetMetadata).","triggerScenarios":"Running 'docker context create --docker from=other-context new-ctx' or 'docker context update --docker from=src' where 'src' either has no Docker endpoint registered in its metadata.Endpoints map, or its endpoint was registered under a different/unknown type. Also fires if the source context was created by a plugin or older CLI version that stored endpoint metadata in an incompatible shape.","commonSituations":"Copying from a context that only has non-Docker endpoints (e.g., a kubernetes-only context); copying from a context whose metadata JSON on disk was hand-edited or corrupted; mixing contexts created by different CLI versions where the EndpointMeta serialization changed.","solutions":["Verify the source context has a Docker endpoint: 'docker context inspect <from-context>' and check that .Endpoints.docker is present.","Re-create the source context with an explicit Docker host: 'docker context create --docker host=... <from-context>'.","Avoid 'from=' and specify the endpoint directly: '--docker host=tcp://host:2376' instead of copying.","If the source context was migrated across CLI versions, remove and recreate it from scratch."],"exampleFix":"# before\ndocker context create --docker from=broken-ctx my-ctx\n# after\ndocker context create --docker host=tcp://docker:2376 my-ctx","handlingStrategy":"validation","validationCode":"// Before create/update with from=<name>, verify the source context\n// has a docker endpoint of the right type.\nfunc sourceHasDockerEndpoint(store store.Reader, name string) error {\n\tmeta, err := store.GetMetadata(name)\n\tif err != nil { return err }\n\tep, ok := meta.Endpoints[docker.DockerEndpoint]\n\tif !ok {\n\t\treturn fmt.Errorf(\"context %q has no docker endpoint to copy\", name)\n\t}\n\tif _, ok := ep.(docker.EndpointMeta); !ok {\n\t\treturn fmt.Errorf(\"context %q docker endpoint is not docker.EndpointMeta\", name)\n\t}\n\treturn nil\n}","typeGuard":"func isDockerEndpointMeta(v any) bool {\n\t_, ok := v.(docker.EndpointMeta)\n\treturn ok\n}","tryCatchPattern":"if err := cli.ContextCreate(...); err != nil {\n\tif strings.Contains(err.Error(), \"unable to get endpoint from context\") {\n\t\t// source context lacks a usable docker endpoint; fall back to explicit --docker host=\n\t}\n}","preventionTips":["Prefer explicit --docker host= over from= when creating contexts.","Inspect the source context's .Endpoints.docker before copying.","Avoid copying from contexts created by plugins or other endpoint types."],"tags":["docker-context","configuration","endpoint","type-assertion"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}