amir20/dozzle · error

container not found

Error message

container not found: %w

What it means

executeFetchContainerLogs resolves the container reference and calls deps.HostService.FindContainer. If no container matches the resolved host/ID pair, the underlying lookup error is wrapped as "container not found" and returned instead of logs.

Solutions

  1. Refresh the container ID via find_containers immediately before fetching logs.
  2. Confirm the host argument matches the host the container currently runs on.
  3. Verify the container exists and is running (`docker ps` or the Dozzle UI); check that the host's Docker client connection is healthy.

Example fix

// before: logs for a recreated container's old id
fetch_container_logs({"containerId":"oldid"})
// after
find_containers({"name":"web"}) -> fetch_container_logs({"containerId": <current id>, "host": <hostId>})
Defensive patterns

Strategy: validation

Validate before calling

const list = await callTool("find_containers", JSON.stringify({ name: targetName }));
if (!list.containers?.length) throw new Error(`container '${targetName}' not found; cannot fetch logs`);
const { id, host } = list.containers[0];

Type guard

function logTarget(c) {
  return typeof c?.id === "string" && typeof c?.host === "string" ? { containerId: c.id, host: c.host } : null;
}

Try / catch

try {
  return await callTool("fetch_container_logs", JSON.stringify({ containerId: id, host }));
} catch (e) {
  if (String(e).includes("container not found")) {
    // container recreated or host wrong; refresh find_containers and retry once
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling fetch_container_logs with a containerId that no longer exists, is running on a different host than the host argument, or a name that does not resolve on that host.

Common situations: Container restarted and got a new ID; agent querying a remote host that is down (so the container appears missing); k8s mode where the pod was rescheduled; using the container display name instead of its actual ID.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


AI-assisted analysis of amir20/dozzle@d9463cbe21 (2026-09-07). Data as JSON: /api/errors/f6358ff54682cbaa. Report an issue: GitHub.

Appendix: source

Thrown at internal/cloud/tools_logs.go:37

	Level       string `json:"level"`
	Query       string `json:"query"`
	Regex       string `json:"regex"`
	Inverse     bool   `json:"inverse"`
}

func executeFetchContainerLogs(ctx context.Context, argsJSON string, deps ToolDeps) (*pb.CallToolResponse, error) {
	var args fetchLogsArgs
	if err := json.Unmarshal([]byte(argsJSON), &args); err != nil {
		return nil, fmt.Errorf("failed to parse arguments: %w", err)
	}
	hostID, containerID, note, err := resolveContainerRefRead(args.ContainerID, args.Host, deps)
	if err != nil {
		return nil, err
	}

	cs, err := deps.HostService.FindContainer(hostID, containerID, deps.Labels)
	if err != nil {
		return nil, fmt.Errorf("container not found: %w", err)
	}

	start := time.Now().Add(-1 * time.Hour)
	end := time.Now()
	if args.Start != "" {
		t, err := time.Parse(time.RFC3339, args.Start)
		if err != nil {
			return nil, fmt.Errorf("invalid start time format (expected RFC3339): %w", err)
		}
		start = t
	}
	if args.End != "" {
		t, err := time.Parse(time.RFC3339, args.End)
		if err != nil {
			return nil, fmt.Errorf("invalid end time format (expected RFC3339): %w", err)
		}
		end = t
	}

View on GitHub (pinned to d9463cbe21)