Use this file to discover all available pages before exploring further.
The Docker struct is the core client for every Bollard API call. Internally it wraps its transport in an Arc, so it is cheaply cloneable — cloning a Docker handle shares the underlying connection pool and version state with the original. All constructor methods return Result<Docker, Error>.
Parameterized TLS connection with explicit certificate paths.
connect_with_ssl and connect_with_ssl_defaults require a Rustls CryptoProvider to be installed before calling. Either enable the ssl (aws-lc-rs) or ssl_ring feature, or call rustls::crypto::CryptoProvider::install_default() manually when using ssl_providerless.
Docker implements Clone cheaply: the internal Arc<Transport>, version Arc, and optional request modifier are all reference-counted. Cloning is the idiomatic way to share a single connection across Tokio tasks.
let docker = Docker::connect_with_unix_defaults().unwrap();let docker2 = docker.clone(); // shares the same connection pool
use bollard::{API_DEFAULT_VERSION, Docker, BollardRequest};use futures_util::FutureExt;#[tokio::main]async fn main() { let http_connector = hyper_util::client::legacy::connect::HttpConnector::new(); let mut client_builder = hyper_util::client::legacy::Client::builder(hyper_util::rt::TokioExecutor::new()); client_builder.pool_max_idle_per_host(0); let client = std::sync::Arc::new(client_builder.build(http_connector)); let docker = Docker::connect_with_custom_transport( move |req: BollardRequest| { let client = std::sync::Arc::clone(&client); Box::pin(async move { client .request(req) .await .map_err(bollard::errors::Error::from) }) }, Some("http://my-custom-docker-server:2735"), 120, API_DEFAULT_VERSION, ) .unwrap(); docker.ping().await.unwrap();}
The timeout applies to every individual HTTP request including streaming calls. For long-running streams such as events or stats, set a generous timeout or use set_timeout(Duration::MAX).