glanceapp/glance · error

fetching containers: %w

Error message

fetching containers: %w

What it means

Top-level wrapper for any failure in fetchDockerContainersFromSource while listing containers from either the Docker Unix socket or a tcp:// remote Docker host. The original error (socket dial failure, request failure, non-200, or JSON decode failure) is preserved with %w, so the suffixed text tells you the real cause.

Source

Thrown at internal/glance/widget-docker-containers.go:163

		return dockerContainerStateIconPaused
	case "exited", "unhealthy", "dead":
		return dockerContainerStateIconWarn
	default:
		return dockerContainerStateIconOther
	}
}

func fetchDockerContainers(
	socketPath string,
	hideByDefault bool,
	category string,
	runningOnly bool,
	formatNames bool,
	labelOverrides map[string]map[string]string,
) (dockerContainerList, error) {
	containers, err := fetchDockerContainersFromSource(socketPath, category, runningOnly, labelOverrides)
	if err != nil {
		return nil, fmt.Errorf("fetching containers: %w", err)
	}

	containers, children := groupDockerContainerChildren(containers, hideByDefault)
	dockerContainers := make(dockerContainerList, 0, len(containers))

	for i := range containers {
		container := &containers[i]

		dc := dockerContainer{
			Name:        deriveDockerContainerName(container, formatNames),
			URL:         container.Labels.getOrDefault(dockerContainerLabelURL, ""),
			Description: container.Labels.getOrDefault(dockerContainerLabelDescription, ""),
			SameTab:     stringToBool(container.Labels.getOrDefault(dockerContainerLabelSameTab, "false")),
			Image:       container.Image,
			State:       strings.ToLower(container.State),
			StateText:   strings.ToLower(container.Status),
			Icon:        newCustomIconField(container.Labels.getOrDefault(dockerContainerLabelIcon, "si:docker")),
		}

View on GitHub (pinned to 91324e8de7)

Solutions

  1. Read the wrapped message after 'fetching containers:' — fix that specific cause first
  2. If glance runs in Docker, mount the socket: -v /var/run/docker.sock:/var/run/docker.sock
  3. Verify permissions: run 'ls -l /var/run/docker.sock' and add the glance user to the docker group if needed
  4. For tcp:// sources, confirm the Docker daemon listens on that address and the port is open

Example fix

# before (glance container without socket)
docker run glance
# after
docker run -v /var/run/docker.sock:/var/run/docker.sock glance
Defensive patterns

Strategy: try-catch

Try / catch

containers, err := fetchDockerContainers(socketPath, hideByDefault, category, runningOnly, formatNames, overrides)
if err != nil {
    slog.Error("docker widget failed", "socket", socketPath, "error", err)
    return dockerContainerList{}, nil // render empty instead of crashing the page
}

Prevention

When it happens

Trigger: Docker socket path wrong or unreadable; glance running in a container without /var/run/docker.sock mounted; remote tcp:// host unreachable; Docker API returning an error status; malformed JSON from a non-Docker endpoint.

Common situations: Glance deployed in Docker without mounting the socket (-v /var/run/docker.sock:/var/run/docker.sock); missing read permission on the socket (user not in the docker group or SELinux denial); pointing at a socket path used by Podman; specifying tcp:// host with wrong port or without TLS config.

Related errors


AI-assisted analysis of glanceapp/glance@91324e8de7 (2026-08-15). Data as JSON: /api/errors/0fa3b6009437c5b7. Report an issue: GitHub.