amir20/dozzle · error
error finding container
Error message
error finding container %s: %v
What it means
After the host~id split succeeds, downloadLogs calls hostService.FindContainer(host, id, userLabels). If the host cannot be reached or no container with that id exists on it, a 400 containing "error finding container %s: %v" is returned with the underlying error appended.
Solutions
- Refresh the container list and use the current container id from the API.
- Verify the host segment matches an available host id/name.
- Check host connectivity (remote agent reachable) before retrying.
Example fix
// before
const stale = JSON.parse(localStorage.getItem('lastContainer'))
download(stale.host + '~' + stale.id)
// after
const containers = await fetch('/api/containers.json').then(r => r.json())
const current = containers.find(c => c.name === stale.name)
if (current) download(current.host + '~' + current.id) Defensive patterns
Strategy: try-catch
Try / catch
try {
const res = await fetch(url);
if (res.status === 400) {
const msg = await res.text();
if (msg.startsWith('error finding container')) await refreshContainersAndRetry();
}
} catch (e) { /* network failure */ } Prevention
- Refresh container ids after any container recreate/upgrade.
- Confirm host connectivity before querying per-container endpoints.
- Don't persist raw host~id across sessions; re-resolve by name.
When it happens
Trigger: GET download with host~id where the host is unknown/disconnected or the container id does not exist (e.g. container was recreated and its id changed).
Common situations: Container recreated after image upgrade so the stored id is stale; agent host offline or removed from the host list; typos in host names when crafting URLs by hand; k8s pod restarts producing new ids.
Understand the failure class
Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.
Related errors
AI-assisted analysis of amir20/dozzle@d9463cbe21 (2026-09-07).
Data as JSON: /api/errors/c8e146917d4a7349.
Report an issue: GitHub.
Appendix: source
Thrown at internal/web/download.go:104
id string
containerService *container_support.ContainerService
}
containers := make([]containerInfo, 0, len(hostIds))
for _, hostId := range hostIds {
parts := strings.Split(hostId, "~")
if len(parts) != 2 {
log.Error().Msgf("invalid host id: %s", hostId)
http.Error(w, fmt.Sprintf("invalid host id: %s", hostId), http.StatusBadRequest)
return
}
host := parts[0]
id := parts[1]
containerService, err := h.hostService.FindContainer(host, id, userLabels)
if err != nil {
log.Error().Err(err).Msgf("error finding container %s", id)
http.Error(w, fmt.Sprintf("error finding container %s: %v", id, err), http.StatusBadRequest)
return
}
containers = append(containers, containerInfo{
hostId: hostId,
host: host,
id: id,
containerService: containerService,
})
}
// Determine zip filename from optional name param or default
zipName := "container-logs"
if name := r.URL.Query().Get("name"); name != "" {
// Sanitize: keep only alphanumeric, hyphens, underscores, dots
sanitized := strings.Map(func(r rune) rune {
if (r >= 'a' && r <= 'z') || (r >= 'A' && r <= 'Z') || (r >= '0' && r <= '9') || r == '-' || r == '_' || r == '.' {
return rView on GitHub (pinned to d9463cbe21)