{"record":{"id":"66ef4b56c6fc8270","repo":"docker/cli","slug":"cannot-find-docker-endpoint-in-context","errorCode":null,"errorMessage":"cannot find docker endpoint in context","messagePattern":"cannot find docker endpoint in context","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/context/docker/load.go","lineNumber":156,"sourceCode":"\treturn result, nil\n}\n\n// isSocket checks if the given address is a Unix-socket (linux),\n// named pipe (Windows), or file-descriptor.\nfunc isSocket(addr string) bool {\n\tswitch proto, _, _ := strings.Cut(addr, \"://\"); proto {\n\tcase \"unix\", \"npipe\", \"fd\":\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}\n\n// EndpointFromContext parses a context docker endpoint metadata into a typed EndpointMeta structure\nfunc EndpointFromContext(metadata store.Metadata) (EndpointMeta, error) {\n\tep, ok := metadata.Endpoints[DockerEndpoint]\n\tif !ok {\n\t\treturn EndpointMeta{}, errors.New(\"cannot find docker endpoint in context\")\n\t}\n\ttyped, ok := ep.(EndpointMeta)\n\tif !ok {\n\t\treturn EndpointMeta{}, fmt.Errorf(\"endpoint %q is not of type EndpointMeta\", DockerEndpoint)\n\t}\n\treturn typed, nil\n}\n","sourceCodeStart":138,"sourceCodeEnd":164,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/context/docker/load.go#L138-L164","documentation":"Returned by EndpointFromContext when the parsed context metadata has no entry under the DockerEndpoint key in its Endpoints map. A docker context must advertise a 'docker' endpoint describing the Engine host; without it the client cannot determine where to connect.","triggerScenarios":"Calling EndpointFromContext on a metadata object produced from a context that only defines non-docker endpoints (e.g. a context for a different orchestrator), or on a hand-crafted/corrupted metadata file missing the docker endpoint key.","commonSituations":"A context created by a third-party tool that did not populate the docker endpoint. A corrupted or partially-written context metadata JSON. Reading a context that was never fully initialized.","solutions":["Recreate the context with 'docker context create <name> --docker host=...' so the docker endpoint is populated.","Inspect the metadata file and confirm it has an 'Endpoints.docker' object with a Host.","Switch to a valid context with 'docker context use <valid-name>'."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"if _, ok := metadata.Endpoints[DockerEndpoint]; !ok {\n    return errors.New(\"context metadata lacks a docker endpoint\")\n}","typeGuard":"func hasDockerEndpoint(m store.Metadata) bool {\n    _, ok := m.Endpoints[DockerEndpoint]\n    return ok\n}","tryCatchPattern":null,"preventionTips":["Always create contexts with --docker host=....","Validate metadata.Endpoints contains the docker key before use.","Recreate contexts from valid sources rather than hand-editing JSON."],"tags":["context","docker-endpoint","metadata","validation"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}