pub fn connect() -> Result<Docker, GenericError>Expand description
Connects to the Docker daemon.
On Windows, this uses Bollard’s platform default connection logic.
On Unix hosts, this searches non-standard socket locations before falling back to Bollard’s default connection logic. Resolution order:
- If
DOCKER_HOSTis set or/var/run/docker.sockexists on disk, defer to Bollard’s default connection logic. - Otherwise, try each candidate socket path in order and use the first that exists.
- If no candidate is found, fall back to
Docker::connect_with_defaults()so the error message comes from Bollard.
§Unix candidate paths
These are checked in order when the standard socket is absent:
| Path | Environment |
|---|---|
$HOME/.docker/run/docker.sock | Docker Desktop |
$HOME/.orbstack/run/docker.sock | OrbStack |
$HOME/.rd/docker.sock | Rancher Desktop |
$HOME/.lima/default/sock/docker.sock | Lima (default instance) |
$HOME/.lima/docker/sock/docker.sock | Lima (docker instance) |
$HOME/.colima/default/docker.sock | Colima |
$HOME/.colima/docker/docker.sock | Colima (docker profile) |
$HOME/.local/share/containers/podman/machine/podman.sock | Podman Desktop (macOS) |
§Errors
Returns an error if no reachable Docker daemon can be found. When connecting through a discovered non-standard Unix socket path, the error includes the path that was attempted.