{"record":{"id":"71a7951fdf726034","repo":"Billionmail/BillionMail","slug":"failed-to-list-containers-w","errorCode":null,"errorMessage":"failed to list containers: %w","messagePattern":"failed to list containers: %w","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/internal/controller/dockerapi/dockerapi_v1_list_container.go","lineNumber":16,"sourceCode":"package dockerapi\n\nimport (\n\t\"billionmail-core/api/dockerapi/v1\"\n\t\"billionmail-core/internal/service/public\"\n\t\"context\"\n\t\"fmt\"\n)\n\nfunc (c *ControllerV1) ListContainer(ctx context.Context, req *v1.ListContainerReq) (res *v1.ListContainerRes, err error) {\n\tres = &v1.ListContainerRes{}\n\n\tres.Data, err = public.DockerApiFromCtx(ctx).ListContainers(ctx)\n\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to list containers: %w\", err)\n\t}\n\n\tres.SetSuccess(public.LangCtx(ctx, \"Success\"))\n\n\treturn\n}\n","sourceCodeStart":1,"sourceCodeEnd":23,"githubUrl":"https://github.com/Billionmail/BillionMail/blob/fc36c76c050c3775c5e899faf7403cf0262d2744/core/internal/controller/dockerapi/dockerapi_v1_list_container.go#L1-L23","documentation":"ListContainer wraps any error returned by public.DockerApiFromCtx(ctx).ListContainers(ctx) with 'failed to list containers: %w'. It is a controller-level passthrough: the Docker API client could not enumerate containers, and the root cause (connection, socket, daemon) is preserved via %w.","triggerScenarios":"Any error from the Docker Engine API call inside ListContainers — Docker daemon not running, unix socket /var/run/docker.sock missing or permission-denied, Docker API unreachable from inside a container (volume not mounted), or API timeout.","commonSituations":"Docker Desktop stopped; app deployed without mounting the docker socket; user not in the 'docker' group (permission denied on socket); DOCKER_HOST misconfigured; Docker daemon restart during the call.","solutions":["Check the wrapped cause (%w) in the returned error — it names the real failure (connection refused, permission denied, no such file).","Verify the Docker daemon is running: 'docker ps' on the host.","If running in a container, mount the socket: -v /var/run/docker.sock:/var/run/docker.sock (or expose DOCKER_HOST to a TCP endpoint).","Fix socket permissions: add the service user to the 'docker' group or relax socket perms."],"exampleFix":"// before\ndocker run billionmail   # socket not mounted -> failed to list containers\n// after\ndocker run -v /var/run/docker.sock:/var/run/docker.sock billionmail","handlingStrategy":"try-catch","validationCode":"sock := os.Getenv(\"DOCKER_HOST\")\nif sock == \"\" {\n\tif _, err := os.Stat(\"/var/run/docker.sock\"); err != nil {\n\t\treturn fmt.Errorf(\"docker socket not available: %w\", err)\n\t}\n}\n// optional pre-check:\n// cli.Ping(ctx) before ListContainers","typeGuard":null,"tryCatchPattern":"res, err := client.ListContainer(ctx, req)\nif err != nil {\n\tif strings.Contains(err.Error(), \"permission denied\") {\n\t\treturn fmt.Errorf(\"docker socket access denied: add user to docker group or mount the socket\")\n\t}\n\tif strings.Contains(err.Error(), \"connection refused\") || strings.Contains(err.Error(), \"no such file\") {\n\t\treturn fmt.Errorf(\"docker daemon unreachable: is it running and the socket mounted?\")\n\t}\n\treturn err\n}","preventionTips":["Mount /var/run/docker.sock when running in a container","Keep the Docker daemon running (systemctl status docker / Docker Desktop)","Add service users to the docker group","Ping the Docker API as a readiness check before container calls"],"tags":["docker","network","container"],"backgroundTag":"docker-daemon-unreachable","analyzedSha":"fc36c76c050c3775c5e899faf7403cf0262d2744","analyzedAt":"2026-09-05T21:28:54.019Z","contentChangedAt":"2026-09-05T21:28:54.019Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}