docker/cli · error

endpoint is not of type EndpointMeta

Error message

endpoint %q is not of type EndpointMeta

What it means

Returned by docker.EndpointFromContext() when the stored endpoint metadata under the "docker" key cannot be type-asserted to docker.EndpointMeta (= context.EndpointMetaBase). The value is present but shaped as a generic map[string]any or a different struct, not the expected typed endpoint.

Solutions

  1. Recreate the context with the current CLI: `docker context create` (or import from an archive produced by a compatible version).
  2. Ensure the store was built with the docker context Config that registers the "docker" endpoint TypeGetter.
  3. If you only need Host/SkipTLSVerify, fall back to reading the endpoint as a generic map[string]any instead of asserting EndpointMeta.

Example fix

// before
ep, err := docker.EndpointFromContext(meta) // panics-free, but errors on schema drift

// after: type-guard the endpoint value
raw := meta.Endpoints[docker.DockerEndpoint]
if m, ok := raw.(docker.EndpointMeta); ok {
    // use m
} else if mm, ok := raw.(map[string]any); ok {
    // tolerant fallback: read mm["Host"] etc.
}
Defensive patterns

Strategy: type-guard

Type guard

// isEndpointMeta narrows a stored endpoint value to docker.EndpointMeta.
func isEndpointMeta(v any) (docker.EndpointMeta, bool) {
    // fast path: already typed
    if m, ok := v.(docker.EndpointMeta); ok {
        return m, true
    }
    // tolerant path: untyped map from a store without the TypeGetter
    if mm, ok := v.(map[string]any); ok {
        host, _ := mm["Host"].(string)
        skip, _ := mm["SkipTLSVerify"].(bool)
        return docker.EndpointMeta{EndpointMetaBase: context.EndpointMetaBase{Host: host, SkipTLSVerify: skip}}, true
    }
    return docker.EndpointMeta{}, false
}

Prevention

When it happens

Trigger: Calling EndpointFromContext(meta) after store.GetMetadata on a context whose "docker" endpoint value is a map[string]any rather than the EndpointMeta struct. This occurs when the store's Config did not register a TypeGetter for the "docker" endpoint, or the context was written by a tool/CLI version with a different endpoint schema.

Common situations: Reading a context created by an older/newer docker CLI with endpoint schema drift; using a store constructed without the docker endpoint TypeGetter; importing a context archive produced by another tool; plugin-provided endpoints read by a CLI lacking that plugin.

Related errors


AI-assisted analysis of docker/cli@4f84911bfe (2026-08-07). Data as JSON: /api/errors/3225a3b876a1b87a. Report an issue: GitHub.

Appendix: source

Thrown at cli/context/docker/load.go:160

// 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)