{"record":{"id":"0fa3b6009437c5b7","repo":"glanceapp/glance","slug":"fetching-containers-w","errorCode":null,"errorMessage":"fetching containers: %w","messagePattern":"fetching containers: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/glance/widget-docker-containers.go","lineNumber":163,"sourceCode":"\t\treturn dockerContainerStateIconPaused\n\tcase \"exited\", \"unhealthy\", \"dead\":\n\t\treturn dockerContainerStateIconWarn\n\tdefault:\n\t\treturn dockerContainerStateIconOther\n\t}\n}\n\nfunc fetchDockerContainers(\n\tsocketPath string,\n\thideByDefault bool,\n\tcategory string,\n\trunningOnly bool,\n\tformatNames bool,\n\tlabelOverrides map[string]map[string]string,\n) (dockerContainerList, error) {\n\tcontainers, err := fetchDockerContainersFromSource(socketPath, category, runningOnly, labelOverrides)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"fetching containers: %w\", err)\n\t}\n\n\tcontainers, children := groupDockerContainerChildren(containers, hideByDefault)\n\tdockerContainers := make(dockerContainerList, 0, len(containers))\n\n\tfor i := range containers {\n\t\tcontainer := &containers[i]\n\n\t\tdc := dockerContainer{\n\t\t\tName:        deriveDockerContainerName(container, formatNames),\n\t\t\tURL:         container.Labels.getOrDefault(dockerContainerLabelURL, \"\"),\n\t\t\tDescription: container.Labels.getOrDefault(dockerContainerLabelDescription, \"\"),\n\t\t\tSameTab:     stringToBool(container.Labels.getOrDefault(dockerContainerLabelSameTab, \"false\")),\n\t\t\tImage:       container.Image,\n\t\t\tState:       strings.ToLower(container.State),\n\t\t\tStateText:   strings.ToLower(container.Status),\n\t\t\tIcon:        newCustomIconField(container.Labels.getOrDefault(dockerContainerLabelIcon, \"si:docker\")),\n\t\t}","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/glanceapp/glance/blob/91324e8de762702e97b0ac5c8e36271d644d8642/internal/glance/widget-docker-containers.go#L145-L181","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Read the wrapped message after 'fetching containers:' — fix that specific cause first","If glance runs in Docker, mount the socket: -v /var/run/docker.sock:/var/run/docker.sock","Verify permissions: run 'ls -l /var/run/docker.sock' and add the glance user to the docker group if needed","For tcp:// sources, confirm the Docker daemon listens on that address and the port is open"],"exampleFix":"# before (glance container without socket)\ndocker run glance\n# after\ndocker run -v /var/run/docker.sock:/var/run/docker.sock glance","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"containers, err := fetchDockerContainers(socketPath, hideByDefault, category, runningOnly, formatNames, overrides)\nif err != nil {\n    slog.Error(\"docker widget failed\", \"socket\", socketPath, \"error\", err)\n    return dockerContainerList{}, nil // render empty instead of crashing the page\n}","preventionTips":["Mount the Docker socket read-only into the glance container at the documented path","Run a startup check: stat the socket and attempt one list call before serving pages","Give the glance process only the docker group membership it needs, nothing broader"],"tags":["docker","unix-socket","container","permissions"],"backgroundTag":null,"analyzedSha":"91324e8de762702e97b0ac5c8e36271d644d8642","analyzedAt":"2026-08-15T14:12:54.279Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}