docker/cli · error

unable to get endpoint from context

Error message

unable to get endpoint from context %q

What it means

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

Solutions

  1. Verify the source context has a Docker endpoint: 'docker context inspect <from-context>' and check that .Endpoints.docker is present.
  2. Re-create the source context with an explicit Docker host: 'docker context create --docker host=... <from-context>'.
  3. Avoid 'from=' and specify the endpoint directly: '--docker host=tcp://host:2376' instead of copying.
  4. If the source context was migrated across CLI versions, remove and recreate it from scratch.

Example fix

# before
docker context create --docker from=broken-ctx my-ctx
# after
docker context create --docker host=tcp://docker:2376 my-ctx
Defensive patterns

Strategy: validation

Validate before calling

// Before create/update with from=<name>, verify the source context
// has a docker endpoint of the right type.
func sourceHasDockerEndpoint(store store.Reader, name string) error {
	meta, err := store.GetMetadata(name)
	if err != nil { return err }
	ep, ok := meta.Endpoints[docker.DockerEndpoint]
	if !ok {
		return fmt.Errorf("context %q has no docker endpoint to copy", name)
	}
	if _, ok := ep.(docker.EndpointMeta); !ok {
		return fmt.Errorf("context %q docker endpoint is not docker.EndpointMeta", name)
	}
	return nil
}

Type guard

func isDockerEndpointMeta(v any) bool {
	_, ok := v.(docker.EndpointMeta)
	return ok
}

Try / catch

if err := cli.ContextCreate(...); err != nil {
	if strings.Contains(err.Error(), "unable to get endpoint from context") {
		// source context lacks a usable docker endpoint; fall back to explicit --docker host=
	}
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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

Appendix: source

Thrown at cli/command/context/options.go:103

			errs = append(errs, errors.New("unrecognized config key: "+k))
		}
	}
	return errors.Join(errs...)
}

func getDockerEndpoint(contextStore store.Reader, config map[string]string) (docker.Endpoint, error) {
	if err := validateConfig(config, allowedDockerConfigKeys); err != nil {
		return docker.Endpoint{}, err
	}
	if contextName, ok := config[keyFrom]; ok {
		metadata, err := contextStore.GetMetadata(contextName)
		if err != nil {
			return docker.Endpoint{}, err
		}
		if ep, ok := metadata.Endpoints[docker.DockerEndpoint].(docker.EndpointMeta); ok {
			return docker.Endpoint{EndpointMeta: ep}, nil
		}
		return docker.Endpoint{}, fmt.Errorf("unable to get endpoint from context %q", contextName)
	}
	tlsData, err := context.TLSDataFromFiles(config[keyCA], config[keyCert], config[keyKey])
	if err != nil {
		return docker.Endpoint{}, err
	}
	skipTLSVerify, err := parseBool(config, keySkipTLSVerify)
	if err != nil {
		return docker.Endpoint{}, err
	}
	ep := docker.Endpoint{
		EndpointMeta: docker.EndpointMeta{
			Host:          config[keyHost],
			SkipTLSVerify: skipTLSVerify,
		},
		TLSData: tlsData,
	}
	// try to resolve a docker client, validating the configuration
	opts, err := ep.ClientOpts()

View on GitHub (pinned to 4f84911bfe)