Skip to main content

connect

Function connect 

Source
pub fn connect() -> Result<Docker, GenericError>
Expand description

Connect to the Docker daemon, searching non-standard socket locations on macOS.

Resolution order:

  1. If DOCKER_HOST is set or /var/run/docker.sock exists on disk, defer to bollard’s default connection logic — no extra work needed.
  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 rather than from us.

§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 path, the error includes the path that was attempted.