{"record":{"id":"52984064a2abba98","repo":"slimtoolkit/slim","slug":"no-unix-socket-found-529840","errorCode":null,"errorMessage":"no unix socket found","messagePattern":"no unix socket found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"pkg/docker/dockerutil/dockerutil.go","lineNumber":122,"sourceCode":"}\n\nfunc HasImage(dclient *dockerapi.Client, imageRef string) (*ImageIdentity, error) {\n\t//NOTES:\n\t//ListImages doesn't filter by image ID (must use ImageInspect instead)\n\t//Check images by name:tag, full or partial image ID or name@digest\n\tif imageRef == \"\" || imageRef == \".\" || imageRef == \"..\" {\n\t\treturn nil, ErrBadParam\n\t}\n\n\tvar err error\n\tif dclient == nil {\n\t\tsocketInfo, err := dockerclient.GetUnixSocketAddr()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tif socketInfo == nil || socketInfo.Address == \"\" {\n\t\t\treturn nil, fmt.Errorf(\"no unix socket found\")\n\t\t}\n\n\t\tdclient, err = dockerapi.NewClient(socketInfo.Address)\n\t\tif err != nil {\n\t\t\tlog.Errorf(\"dockerutil.HasImage(%s): dockerapi.NewClient() error = %v\", imageRef, err)\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\timageInfo, err := dclient.InspectImage(imageRef)\n\tif err != nil {\n\t\tif err == dockerapi.ErrNoSuchImage {\n\t\t\treturn nil, ErrNotFound\n\t\t}\n\n\t\treturn nil, err\n\t}\n","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/slimtoolkit/slim/blob/81940d17fa112cc678e32209214bcb2355cb3004/pkg/docker/dockerutil/dockerutil.go#L104-L140","documentation":"dockerutil.HasImage needs a Docker client, which it creates from the address returned by dockerclient.GetUnixSocketAddr(). When that returns nil or an empty Address, the function refuses to proceed with fmt.Errorf(\"no unix socket found\"). It means the Docker daemon's unix socket could not be located on this host.","triggerScenarios":"Calling HasImage (or its wrappers NoImage/HasEmptyImage) when GetUnixSocketAddr returns a nil SocketInfo or a SocketInfo with an empty Address — i.e. no docker.sock found at the standard paths or via DOCKER_HOST discovery.","commonSituations":"Running the agent in a container without mounting /var/run/docker.sock; Docker not installed or daemon not running; non-standard socket path not conveyed through environment/config; rootless Docker with a socket in a non-default location.","solutions":["Mount the Docker socket into the container: -v /var/run/docker.sock:/var/run/docker.sock","Verify the daemon is running (systemctl status docker / docker ps works on the host)","Set DOCKER_HOST (e.g. unix:///path/to/docker.sock) so GetUnixSocketAddr can discover a non-default socket path","Check the socket path the code expects and symlink/adjust it (ln -s /run/user/1000/docker.sock /var/run/docker.sock for rootless Docker)"],"exampleFix":"// before\ndocker run --rm myagent   # no unix socket found\n// after\ndocker run --rm -v /var/run/docker.sock:/var/run/docker.sock myagent","handlingStrategy":"validation","validationCode":"func dockerSocketAvailable() error {\n    addr := os.Getenv(\"DOCKER_HOST\")\n    if addr != \"\" && !strings.HasPrefix(addr, \"unix://\") && !strings.HasPrefix(addr, \"tcp://\") {\n        return fmt.Errorf(\"invalid DOCKER_HOST %q\", addr)\n    }\n    if fi, err := os.Stat(\"/var/run/docker.sock\"); err != nil || fi.Mode()&os.ModeSocket == 0 {\n        return fmt.Errorf(\"docker socket not present at /var/run/docker.sock\")\n    }\n    return nil\n}\n// call before HasImage; abort with a clear config error if it fails","typeGuard":"func hasDockerSocket() bool {\n    fi, err := os.Stat(\"/var/run/docker.sock\")\n    return err == nil && fi.Mode()&os.ModeSocket != 0\n}","tryCatchPattern":"_, err := dockerutil.HasImage(img)\nif err != nil && strings.Contains(err.Error(), \"no unix socket found\") {\n    log.Error(\"Docker socket not found: mount /var/run/docker.sock or set DOCKER_HOST\")\n    return ErrDockerUnavailable\n}","preventionTips":["Always mount /var/run/docker.sock when running the agent in a container","Set DOCKER_HOST explicitly in deployment manifests","Health-check the socket at startup and fail fast with a clear message","For rootless Docker, symlink or configure the /run/user/<uid> socket path"],"tags":["docker","unix-socket","environment"],"backgroundTag":"docker-socket-not-found","analyzedSha":"81940d17fa112cc678e32209214bcb2355cb3004","analyzedAt":"2026-08-31T23:06:12.682Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}