Bollard uses Rustls to establish mutually-authenticated TLS connections to remote Docker daemons. Both the server certificate authority chain and the client certificate/key are configured through environment variables or passed directly to the connection constructor.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.
SSL/TLS support requires exactly one crypto-provider feature flag. Enabling more than one will cause a compile-time error. See the feature flags section below for the full list.
Docker::connect_with_ssl_defaults
Reads the target host from DOCKER_HOST (falling back to tcp://localhost:2375) and locates certificates in the directory pointed to by DOCKER_CERT_PATH. The expected files are:
| File | Purpose |
|---|---|
key.pem | Client private key |
cert.pem | Client certificate |
ca.pem | Certificate authority chain used to verify the server |
Function signature
Address resolution
DOCKER_HOSTenvironment variable (e.g.tcp://docker.example.com:2376).- Falls back to
"tcp://localhost:2375"if unset.
Certificate resolution (default_cert_path)
The helper DockerClientCertResolver::default_cert_path() determines the certificate directory using this precedence:
DOCKER_CERT_PATHenvironment variable.DOCKER_CONFIGenvironment variable.~/.docker(home directory fallback).
Docker::connect_with_ssl
Pass all parameters explicitly — useful when certificates are stored outside the default location, or when you need to connect to multiple daemons with different credentials.
Function signature
| Parameter | Type | Description |
|---|---|---|
addr | &str | Target URL — tcp:// or https:// scheme accepted. |
ssl_key | &Path | Path to the PEM-encoded private key (key.pem). |
ssl_cert | &Path | Path to the PEM-encoded client certificate (cert.pem). |
ssl_ca | &Path | Path to the PEM-encoded CA chain (ca.pem). |
timeout | u64 | Read/write timeout in seconds. |
client_version | &ClientVersion | Docker API version to request. |
Environment Variables
| Variable | Description |
|---|---|
DOCKER_HOST | URL of the Docker daemon, e.g. tcp://docker.example.com:2376. |
DOCKER_CERT_PATH | Directory containing key.pem, cert.pem, and ca.pem. |
DOCKER_CONFIG | Fallback directory for certificates when DOCKER_CERT_PATH is not set. |
DOCKER_TLS_VERIFY | When set (any non-empty value), connect_with_host will automatically use SSL for tcp:// addresses. |
Feature Flags
Choose exactly one crypto provider. Enabling multiple providers will produce a compile error.ssl (recommended)
Rustls backed by the ring cryptography library. This is the recommended option for most applications.
aws-lc-rs (FIPS)
Rustls backed by aws-lc-rs. Use this when FIPS 140-3 compliance is required.
ssl_providerless
Rustls without a bundled crypto provider. You must call
CryptoProvider::install_default() before creating any connection. Intended for advanced use cases that supply their own provider.webpki
Replaces OS-native root certificates with Mozilla’s WebPKI root store. Can be combined with any of the above provider features.
Complete Example
Generate TLS certificates (server side)
Use Docker’s built-in
dockerd TLS generation or cert-manager to create your CA, server, and client certificate/key pairs. Place ca.pem, cert.pem, and key.pem in a known directory.