docker/cli · error
cannot find docker endpoint in context
Error message
cannot find docker endpoint in context
What it means
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.
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>'.
Defensive patterns
Strategy: type-guard
Validate before calling
if _, ok := metadata.Endpoints[DockerEndpoint]; !ok {
return errors.New("context metadata lacks a docker endpoint")
} Type guard
func hasDockerEndpoint(m store.Metadata) bool {
_, ok := m.Endpoints[DockerEndpoint]
return ok
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- context metadata is not a valid DockerContext
- docker endpoint configuration is required
- unrecognized config key
- failed to retrieve context tls info: ca.pem seems invalid
- no valid private key found
AI-assisted analysis of docker/cli@4f84911bfe (2026-08-07).
Data as JSON: /api/errors/66ef4b56c6fc8270.
Report an issue: GitHub.
Appendix: source
Thrown at cli/context/docker/load.go:156
return result, nil
}
// isSocket checks if the given address is a Unix-socket (linux),
// named pipe (Windows), or file-descriptor.
func isSocket(addr string) bool {
switch proto, _, _ := strings.Cut(addr, "://"); proto {
case "unix", "npipe", "fd":
return true
default:
return false
}
}
// EndpointFromContext parses a context docker endpoint metadata into a typed EndpointMeta structure
func EndpointFromContext(metadata store.Metadata) (EndpointMeta, error) {
ep, ok := metadata.Endpoints[DockerEndpoint]
if !ok {
return EndpointMeta{}, errors.New("cannot find docker endpoint in context")
}
typed, ok := ep.(EndpointMeta)
if !ok {
return EndpointMeta{}, fmt.Errorf("endpoint %q is not of type EndpointMeta", DockerEndpoint)
}
return typed, nil
}
View on GitHub (pinned to 4f84911bfe)