Tencent/WeKnora · error
daemon returned no container state
Error message
daemon returned no container state
What it means
Connect inspects the container via the Docker API and switches on its State to decide whether to restart, unpause, or adopt it. If the daemon's inspect response has a nil State, there is no status to act on, so Connect fails with this error wrapped by dockerError. It indicates a daemon/consistency anomaly, not normal lifecycle states.
Source
Thrown at internal/sandbox/docker_remote_client.go:388
}
return "bridge"
}
// Connect re-attaches to an existing container, resuming it when the daemon
// or the host stopped it. This is the docker equivalent of E2B's auto-resume:
// a stopped container keeps its filesystem, so the session continues where it
// left off instead of losing everything it installed.
func (c *DockerRemoteClient) Connect(
ctx context.Context,
sandboxID string,
) (RemoteSandboxHandle, error) {
inspected, err := c.api.ContainerInspect(ctx, sandboxID, client.ContainerInspectOptions{})
if err != nil {
return nil, dockerError("Connect", err)
}
state := inspected.Container.State
if state == nil {
return nil, dockerError("Connect", errors.New("daemon returned no container state"))
}
switch dockerStateOf(state.Status) {
case RemoteStateTerminal:
return nil, &RemoteError{
Kind: RemoteErrorKindTerminal,
Provider: SandboxTypeDocker,
Op: "Connect",
Message: "container is dead",
}
case RemoteStatePaused:
if err := c.resume(ctx, inspected.Container.ID, string(state.Status), "Connect"); err != nil {
return nil, err
}
if err := c.waitUntilRunning(ctx, inspected.Container.ID, "Connect"); err != nil {
return nil, err
}
}
c.sweepInBackground(ctx)View on GitHub (pinned to 988cbb0330)
Solutions
- Inspect the ContainerInspect response/daemon and ensure State is populated (the inspect payload should include state)
- Retry Connect — a transient daemon race may resolve on a subsequent inspect
- If this comes from a fake/test API, fix the stub to return a State (e.g. Status running/stopped)
- Check Docker daemon version compatibility with the API client
Example fix
// stubbed inspect in tests
// before
return &client.ContainerInspectResult{Container: &client.ContainerData{}}, nil
// after
return &client.ContainerInspectResult{Container: &client.ContainerData{State: &client.ContainerState{Status: "running"}}}, nil Defensive patterns
Strategy: try-catch
Type guard
func hasContainerState(c *client.ContainerData) bool { return c != nil && c.State != nil } Try / catch
handle, err := sbx.Connect(ctx, id)
var rerr *sandbox.RemoteError
if errors.As(err, &rerr) && strings.Contains(rerr.Error(), "daemon returned no container state") {
// transient daemon anomaly: retry once, then surface
handle, err = sbx.Connect(ctx, id)
}
if err != nil { return err } Prevention
- Retry Connect once on daemon-state anomalies before failing
- In tests, make fake ContainerInspect responses fully populate State
- Pin a Docker daemon version compatible with the API client and monitor daemon health
When it happens
Trigger: Calling Connect (TestDockerClientConnect* paths) when ContainerInspect returns a Container whose State field is nil — e.g. a stubbed/fake API returning an incomplete inspect result, or a daemon race where the container record exists without state.
Common situations: Testing against mock ContainerInspect implementations that forget to populate State; Docker daemon version changes that alter inspect payload shape; transient daemon inconsistency right after container creation.
Related errors
- invalid script
- sandbox: docker client requires a config
- sandbox: docker backend requires an image
- sandbox: docker backend is disabled; enable it in System Set
- e2b remote client config is required
AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02).
Data as JSON: /api/errors/2b334588463989f8.
Report an issue: GitHub.