Skip to main content

connect

Function connect 

Source
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:

  1. If DOCKER_HOST is set or /var/run/docker.sock exists on disk, defer to Bollard’s default connection logic.
  2. Otherwise, try each candidate socket path in order and use the first that exists.
  3. 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:

PathEnvironment
$HOME/.docker/run/docker.sockDocker Desktop
$HOME/.orbstack/run/docker.sockOrbStack
$HOME/.rd/docker.sockRancher Desktop
$HOME/.lima/default/sock/docker.sockLima (default instance)
$HOME/.lima/docker/sock/docker.sockLima (docker instance)
$HOME/.colima/default/docker.sockColima
$HOME/.colima/docker/docker.sockColima (docker profile)
$HOME/.local/share/containers/podman/machine/podman.sockPodman 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.