slimtoolkit/slim · critical
no unix socket found
Error message
no unix socket found
What it means
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.
Source
Thrown at pkg/docker/dockerutil/dockerutil.go:122
}
func HasImage(dclient *dockerapi.Client, imageRef string) (*ImageIdentity, error) {
//NOTES:
//ListImages doesn't filter by image ID (must use ImageInspect instead)
//Check images by name:tag, full or partial image ID or name@digest
if imageRef == "" || imageRef == "." || imageRef == ".." {
return nil, ErrBadParam
}
var err error
if dclient == nil {
socketInfo, err := dockerclient.GetUnixSocketAddr()
if err != nil {
return nil, err
}
if socketInfo == nil || socketInfo.Address == "" {
return nil, fmt.Errorf("no unix socket found")
}
dclient, err = dockerapi.NewClient(socketInfo.Address)
if err != nil {
log.Errorf("dockerutil.HasImage(%s): dockerapi.NewClient() error = %v", imageRef, err)
return nil, err
}
}
imageInfo, err := dclient.InspectImage(imageRef)
if err != nil {
if err == dockerapi.ErrNoSuchImage {
return nil, ErrNotFound
}
return nil, err
}
View on GitHub (pinned to 81940d17fa)
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)
Example fix
// before docker run --rm myagent # no unix socket found // after docker run --rm -v /var/run/docker.sock:/var/run/docker.sock myagent
Defensive patterns
Strategy: validation
Validate before calling
func dockerSocketAvailable() error {
addr := os.Getenv("DOCKER_HOST")
if addr != "" && !strings.HasPrefix(addr, "unix://") && !strings.HasPrefix(addr, "tcp://") {
return fmt.Errorf("invalid DOCKER_HOST %q", addr)
}
if fi, err := os.Stat("/var/run/docker.sock"); err != nil || fi.Mode()&os.ModeSocket == 0 {
return fmt.Errorf("docker socket not present at /var/run/docker.sock")
}
return nil
}
// call before HasImage; abort with a clear config error if it fails Type guard
func hasDockerSocket() bool {
fi, err := os.Stat("/var/run/docker.sock")
return err == nil && fi.Mode()&os.ModeSocket != 0
} Try / catch
_, err := dockerutil.HasImage(img)
if err != nil && strings.Contains(err.Error(), "no unix socket found") {
log.Error("Docker socket not found: mount /var/run/docker.sock or set DOCKER_HOST")
return ErrDockerUnavailable
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of slimtoolkit/slim@81940d17fa (2026-08-31).
Data as JSON: /api/errors/52984064a2abba98.
Report an issue: GitHub.