Bollard provides first-class support for connecting to a locally running Docker daemon. On Linux and macOS it communicates over a Unix domain socket; on Windows it uses a Named Pipe. The helper methods below abstract away the platform difference so most code can be written once and run anywhere.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/fussybeaver/bollard/llms.txt
Use this file to discover all available pages before exploring further.
Auto-detect the Best Local Connection
Docker::connect_with_local_defaults() is the recommended starting point for local connections. On Unix it delegates to connect_with_unix_defaults; on Windows it delegates to connect_with_named_pipe_defaults. Both variants respect the Docker CLI precedence for host resolution (DOCKER_HOST env var → DOCKER_CONTEXT env var → currentContext in ~/.docker/config.json → platform default).
Docker::connect_with_local when you need to supply an explicit socket path, timeout, or API version:
Function signatures
Both methods require the
pipe feature flag, which is enabled by default. If you have disabled default features, add features = ["pipe"] to your Cargo.toml dependency.Unix Socket (Linux / macOS)
connect_with_socket_defaults
Connects to the standard Unix socket path /var/run/docker.sock (or //./pipe/docker_engine on Windows). This is a cross-platform convenience wrapper around connect_with_unix / connect_with_named_pipe.
connect_with_socket
Parameterised variant — supply any Unix socket path, a timeout in seconds, and an API ClientVersion.
Function signatures
connect_with_unix_defaults / connect_with_unix
Lower-level Unix-only methods. connect_with_unix_defaults resolves the host using the Docker CLI precedence chain before falling back to DEFAULT_SOCKET.
Function signatures
Windows Named Pipe
connect_with_named_pipe_defaults
Connects to the standard Windows named pipe //./pipe/docker_engine. Respects the Docker CLI host-resolution precedence; falls back to DEFAULT_NAMED_PIPE when the resolved host is not an npipe:// address.
connect_with_named_pipe
Parameterised variant for custom pipe paths.
Function signatures
Constants
The following public constants define the default addresses used by the connection helpers:| Constant | Platform | Value |
|---|---|---|
DEFAULT_SOCKET | Unix | "unix:///var/run/docker.sock" |
DEFAULT_NAMED_PIPE | Windows | "npipe:////./pipe/docker_engine" |
DEFAULT_DOCKER_HOST | Unix | alias of DEFAULT_SOCKET |
DEFAULT_DOCKER_HOST | Windows | alias of DEFAULT_NAMED_PIPE |
Feature Flags
pipe (default)
Enables Unix socket and Windows named pipe transports. Required by all connection methods on this page. Included in the default feature set — no extra configuration needed for most projects.
Minimal binary
To reduce binary size, disable default features and re-enable only what you need:
