{"record":{"id":"afdc9a4aa60c4297","repo":"juanfont/headscale","slug":"listing-images-w","errorCode":null,"errorMessage":"listing images: %w","messagePattern":"listing images: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/hi/cleanup.go","lineNumber":264,"sourceCode":"\t\tfmt.Println(\"No unused networks found to remove\")\n\t}\n\n\treturn nil\n}\n\n// cleanOldImages removes test-related and old dangling Docker images.\nfunc cleanOldImages(ctx context.Context) error {\n\tcli, err := createDockerClient(ctx)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"creating Docker client: %w\", err)\n\t}\n\tdefer cli.Close()\n\n\timages, err := cli.ImageList(ctx, image.ListOptions{\n\t\tAll: true,\n\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"listing images: %w\", err)\n\t}\n\n\tremoved := 0\n\n\tfor _, img := range images {\n\t\tshouldRemove := false\n\n\t\tfor _, tag := range img.RepoTags {\n\t\t\tif strings.Contains(tag, \"hs-\") ||\n\t\t\t\tstrings.Contains(tag, \"headscale-integration\") ||\n\t\t\t\tstrings.Contains(tag, \"tailscale\") {\n\t\t\t\tshouldRemove = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tif len(img.RepoTags) == 0 && time.Unix(img.Created, 0).Before(time.Now().Add(-7*24*time.Hour)) {\n\t\t\tshouldRemove = true","sourceCodeStart":246,"sourceCodeEnd":282,"githubUrl":"https://github.com/juanfont/headscale/blob/565fd254d06c4c7f9a8cad1714a43445c79ba420/cmd/hi/cleanup.go#L246-L282","documentation":"Returned by cleanOldImages when cli.ImageList(All:true) fails while enumerating images to find test-related ones (hs-*, headscale-integration, tailscale). API-level failure causes: daemon unreachable mid-call, permission denial, API version mismatch, or proxies blocking the /images/json endpoint.","triggerScenarios":"Running `hi cleanup` when the daemon restarts; DOCKER_API_VERSION pinned to an unsupported value; docker-socket proxy without IMAGES enabled; remote daemon connection dropped.","commonSituations":"Socket proxies with narrow whitelists in CI; daemon upgrades mid-session; flaky remote contexts; disk-full daemons refusing some API calls.","solutions":["Reproduce manually: docker images -a","Enable the images endpoint on socket proxies (-e IMAGES=1)","Unset DOCKER_API_VERSION; upgrade very old engines","Retry after daemon connectivity is restored"],"exampleFix":"# docker-socket-proxy: allow image listing\n-e IMAGES=1","handlingStrategy":"retry","validationCode":"docker images -a   # must succeed; repro of cli.ImageList","typeGuard":null,"tryCatchPattern":"Reproduce with docker images; proxy whitelist issues appear there directly. Retry transient failures after daemon recovery.","preventionTips":["Enable IMAGES=1 on socket proxies","Avoid pinning DOCKER_API_VERSION globally in shell profiles","Keep the daemon stable during cleanup jobs"],"tags":["docker","images","container-list","cleanup"],"backgroundTag":null,"analyzedSha":"565fd254d06c4c7f9a8cad1714a43445c79ba420","analyzedAt":"2026-08-15T13:12:30.133Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}