{"record":{"id":"b3aa7e5c08cb735d","repo":"vxcontrol/pentagi","slug":"container-runtime-is-not-operational","errorCode":null,"errorMessage":"container runtime is not operational","messagePattern":"container runtime is not operational","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"backend/pkg/tools/terminal.go","lineNumber":209,"sourceCode":"\tctx context.Context,\n\tcwd, command string,\n\tdetach bool,\n\ttimeout time.Duration,\n) (string, error) {\n\tcontainerName := PrimaryTerminalName(t.tenantPrefix, t.flowID)\n\n\tcmd := []string{\n\t\t\"sh\",\n\t\t\"-c\",\n\t\tcommand,\n\t}\n\n\tisRunning, err := t.dockerClient.IsContainerRunning(ctx, t.containerLID)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"runtime verification failed: %w\", err)\n\t}\n\tif !isRunning {\n\t\treturn \"\", fmt.Errorf(\"container runtime is not operational\")\n\t}\n\n\tif cwd == \"\" {\n\t\tcwd = docker.WorkFolderPathInContainer\n\t}\n\n\t// Format command with working directory and ANSI styling\n\tstyledCommand := fmt.Sprintf(\"%s $ %s%s%s%s\", cwd, ansiColorInputCmd, command, ansiColorReset, ansiLineTerminator)\n\t_, err = t.tlp.PutMsg(ctx, database.TermlogTypeStdin, styledCommand, t.containerID, t.taskID, t.subtaskID)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to put terminal log (stdin): %w\", err)\n\t}\n\n\ttimeout = t.normalizeExecTimeout(timeout)\n\n\tcreateResp, err := t.dockerClient.ContainerExecCreate(ctx, containerName, client.ExecCreateOptions{\n\t\tCmd:          cmd,\n\t\tAttachStdout: true,","sourceCodeStart":191,"sourceCodeEnd":227,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/tools/terminal.go#L191-L227","documentation":"After the Docker check succeeds, ExecCommand refuses to run if IsContainerRunning reports the terminal container is not running. The literal message \"container runtime is not operational\" means the sandbox for this flow is stopped/exited, so no command can be executed.","triggerScenarios":"ExecCommand called when the flow's terminal container has exited — it crashed, was stopped manually, OOM-killed, finished its entrypoint, or was removed by a reaper while the flow still references it.","commonSituations":"Long-running flow whose sandbox exited between steps; container stopped via docker stop during debugging; image entrypoint exiting immediately after creation; resource limits (OOM) killing the container mid-flow.","solutions":["Start the container again: docker start <container> (or recreate it via the platform's flow/terminal provisioning)","Check why it exited: docker inspect -f '{{.State.ExitCode}} {{.State.Error}}' <container> and container logs","If the container was removed, re-create the terminal for the flow and retry the command"],"exampleFix":"// before\nout, err := term.ExecCommand(ctx, cwd, cmd, false, timeout) // container runtime is not operational\n// after\nif running, _ := docker.IsContainerRunning(ctx, lid); !running {\n    if err := term.EnsureRunning(ctx); err != nil { return err } // restart/recreate sandbox\n}\nout, err := term.ExecCommand(ctx, cwd, cmd, false, timeout)","handlingStrategy":"fallback","validationCode":"running, err := dockerClient.IsContainerRunning(ctx, containerLID)\nif err != nil {\n    return fmt.Errorf(\"cannot verify container: %w\", err)\n}\nif !running {\n    return fmt.Errorf(\"terminal container %s is stopped; start or recreate it before executing\", containerLID)\n}","typeGuard":null,"tryCatchPattern":"out, err := term.ExecCommand(ctx, cwd, cmd, false, timeout)\nif err != nil && err.Error() == \"container runtime is not operational\" {\n    if rerr := term.EnsureRunning(ctx); rerr != nil { // restart/recreate fallback\n        return fmt.Errorf(\"sandbox restart failed: %w\", rerr)\n    }\n    out, err = term.ExecCommand(ctx, cwd, cmd, false, timeout)\n}","preventionTips":["Use restart policies (e.g. on-flow keepalive) so sandboxes don't silently exit","Track container exit events and recreate the terminal proactively","Check exit codes/logs when a container dies to fix the root cause (OOM, bad entrypoint)","Don't hold flow references to containers removed by external cleanup jobs"],"tags":["docker","container","sandbox","lifecycle"],"backgroundTag":"container-not-running","analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}