jesseduffield/lazydocker · error

expected docker.EndpointMeta, got %T

Error message

expected docker.EndpointMeta, got %T

What it means

In getEndpointHostFromContext (docker.go), after loading metadata for the current docker context, the endpoint entry under docker.DockerEndpoint is type-asserted to ddocker.EndpointMeta. If the CLI stored a different concrete type in the context store (the docker CLI has several endpoint metadata implementations), the assertion fails and this error reports the actual %T. It means the context exists but its shape is one lazydocker does not understand.

Source

Thrown at pkg/commands/docker.go:571

	}

	storeConfig := ctxstore.NewConfig(
		func() interface{} { return &ddocker.EndpointMeta{} },
		ctxstore.EndpointTypeGetter(ddocker.DockerEndpoint, func() interface{} { return &ddocker.EndpointMeta{} }),
	)

	st := ctxstore.New(cliconfig.ContextStoreDir(), storeConfig)
	md, err := st.GetMetadata(currentContext)
	if err != nil {
		return "", err
	}
	dockerEP, ok := md.Endpoints[ddocker.DockerEndpoint]
	if !ok {
		return "", err
	}
	dockerEPMeta, ok := dockerEP.(ddocker.EndpointMeta)
	if !ok {
		return "", fmt.Errorf("expected docker.EndpointMeta, got %T", dockerEP)
	}

	if dockerEPMeta.Host != "" {
		return dockerEPMeta.Host, nil
	}

	// We might end up here, if the context was created with the `host` set to an empty value (i.e. '').
	// For example:
	// ```sh
	// docker context create foo --docker "host="
	// ```
	// In such scenario, we mimic the `docker` cli and try to connect to the "default docker host".
	return defaultDockerHost, nil
}

View on GitHub (pinned to 7e7aadc207)

Solutions

  1. Switch to a plain context: `docker context use default` (or recreate with `docker context create foo --docker host=ssh://user@host`) so the store holds the standard EndpointMeta.
  2. Upgrade/downgrade so lazydocker and the docker CLI agree on context store schema — reinstall the same Docker version that created the contexts.
  3. Inspect the store: `docker context ls` and check ~/.docker/contexts/meta/*/meta.json to see what is stored; recreate any context whose docker endpoint looks unusual.
  4. As a workaround set DOCKER_HOST explicitly, which avoids context metadata lookup entirely.

Example fix

# before
docker context use weird-tool-context   # non-standard metadata
lazydocker                              # 'expected docker.EndpointMeta, got ...'

# after
docker context use default
lazydocker
# or: DOCKER_HOST=ssh://user@host lazydocker
Defensive patterns

Strategy: type-guard

Type guard

dockerEPMeta, ok := dockerEP.(ddocker.EndpointMeta)
if !ok {
    // fall back to default host instead of failing hard
    return defaultDockerHost(), nil
}

Try / catch

host, err := getEndpointHostFromContext()
if err != nil && strings.Contains(err.Error(), "expected docker.EndpointMeta") {
    host = "unix:///var/run/docker.sock" // sensible default
}

Prevention

When it happens

Trigger: Starting lazydocker with DOCKER_HOST unset and the active docker context created by a tool or CLI version that writes a non-standard endpoint metadata type into the context store (e.g. contexts with additional endpoint plugins or different metadata structs).

Common situations: Contexts created/modified by docker desktop, test frameworks, or context orchestrators; mixed docker CLI versions on one machine (older/newer context store schema); contexts where the docker endpoint key holds a nil or plugin-specific value.

Related errors


AI-assisted analysis of jesseduffield/lazydocker@7e7aadc207 (2026-08-15). Data as JSON: /api/errors/9c3698132180a89d. Report an issue: GitHub.