Skip to main content

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.

Bollard is published to crates.io and can be added to any Rust project via Cargo. The crate uses Cargo feature flags to keep the default binary small while making optional capabilities — TLS, SSH, BuildKit, WebSocket, and datetime support — available on demand.

Basic Installation

Add bollard and a Tokio runtime to your Cargo.toml:
Cargo.toml
[dependencies]
bollard = "0.21"
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }
The default feature set enables http (HTTP/TCP transport) and pipe (Unix sockets and Windows named pipes). This covers local Docker access on all platforms and remote access over plain TCP without TLS.

Quick Start: Choosing Features by Use Case

Use CaseCargo.toml
Local Docker (Unix / Windows)bollard = "0.21" (defaults work)
Remote Docker over HTTPSbollard = { version = "0.21", features = ["ssl"] }
SSH tunnel to remote Dockerbollard = { version = "0.21", features = ["ssh"] }
BuildKit image buildsbollard = { version = "0.21", features = ["buildkit", "chrono"] }
WebSocket container attachbollard = { version = "0.21", features = ["websocket"] }
Minimal binary sizebollard = { version = "0.21", default-features = false, features = ["pipe"] }

Feature Flag Reference

Default Features

Two features are enabled automatically. You can opt out with default-features = false.
FeatureDescription
httpHTTP/TCP connector — enables DOCKER_HOST=tcp://... connections
pipeUnix socket (Linux/macOS) and Windows named pipe for local Docker/Podman

Transport Features

FeatureDescription
httpHTTP/TCP connector for remote Docker/Podman
pipeUnix socket / Windows named pipe for local Docker/Podman
sshSSH tunnel connector via openssh

TLS / SSL Features

These features add encrypted transport using Rustls. Pick one crypto provider:
FeatureDescription
sslRustls with the ring crypto provider — recommended for most projects
aws-lc-rsRustls with the aws-lc-rs provider — FIPS-compliant
ssl_providerlessRustls without a bundled crypto provider — bring your own CryptoProvider
webpkiUse Mozilla’s root certificates (via webpki-roots) instead of OS-native certificates
Do not enable both ssl and aws-lc-rs at the same time. They bundle different crypto backends and will conflict. Choose one.

DateTime Features

These features add timestamp support in Docker events and log messages. Pick one:
FeatureDescription
chronoChrono date/time types for timestamps
timeTime 0.3 date/time types for timestamps
chrono and time are mutually exclusive. Enabling both will cause a compilation error. Choose whichever datetime library your project already uses.

BuildKit Features

FeatureDescription
buildkitFull BuildKit support, including gRPC transport. Automatically enables ssl.
buildkit_providerlessBuildKit support without a bundled TLS crypto provider — bring your own CryptoProvider.
BuildKit requires either chrono or time to be enabled for timestamp handling in build sessions. Without one of them, the crate will not compile when buildkit is active.
Cargo.toml
# BuildKit with Chrono timestamps
bollard = { version = "0.21", features = ["buildkit", "chrono"] }

WebSocket Features

FeatureDescription
websocketEnables Docker::attach_container_websocket using tokio-tungstenite

Development Features

FeatureDescription
json_data_contentInclude the raw JSON payload inside deserialization error messages — useful for debugging API responses

Cargo.toml Configuration Examples

[dependencies]
bollard = "0.21"
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }
futures-util = "0.3"

Verifying Your Installation

After updating Cargo.toml, run cargo build to fetch and compile Bollard and its dependencies. Then confirm the connection with a quick version check:
src/main.rs
use bollard::Docker;

#[tokio::main]
async fn main() {
    let docker = Docker::connect_with_local_defaults().unwrap();
    let version = docker.version().await.unwrap();
    println!("{:#?}", version);
}
cargo run
A successful run prints the daemon’s API version, platform, and component information.
The full API reference is available at docs.rs/bollard. Documentation is built with the ssl and ssh features enabled, so all transport methods appear in the online docs.

Next Steps

Introduction

Learn about Bollard’s architecture, modules, and API version support.

Quickstart

Connect to a daemon, list containers, and stream stats with working code examples.

Build docs developers (and LLMs) love