Use this file to discover all available pages before exploring further.
The image API covers pulling, building, inspecting, tagging, pushing, exporting, importing, and pruning Docker images. All methods are on the Docker struct. Options builders live in bollard::query_parameters; model structs live in bollard::models. Registry authentication uses bollard::auth::DockerCredentials.
Creates an image by pulling it from a registry or importing it from a tar archive. Progress updates are streamed as CreateImageInfo items. Errors embedded in the stream (e.g. network failures mid-pull) are surfaced as Err(DockerStreamError).Options:CreateImageOptionsBuilder
Field
Type
Description
from_image
&str
Name (and optional tag) of the image to pull (e.g. "alpine:latest").
from_src
&str
URL or - when importing from a tar body via root_fs.
Returns the image digest and platform information by contacting the registry directly. Useful to check what would be pulled before actually pulling.Returns:DistributionInspect — contains descriptor (digest, media type, size) and platforms.
Returns the parent layers of an image in reverse chronological order. Each item includes the layer ID, creation timestamp, and the command that created it.Returns:Vec<ImageHistoryResponseItem>
Pushes an image to a registry. Progress updates and errors are streamed. Errors embedded in the stream are surfaced as Err(DockerStreamError).Options:PushImageOptionsBuilder
Builds an image from a tar archive containing a Dockerfile. Use bollard::body_full(bytes) for in-memory tarballs or bollard::body_stream(stream) for streaming uploads. Build output is streamed as BuildInfo items.Options:BuildImageOptionsBuilder
Field
Type
Description
t
&str
Name and optional tag for the built image (e.g. "myapp:latest").
dockerfile
&str
Path to the Dockerfile inside the tar context. Default "Dockerfile".
pull
&str
Always pull a newer version of the base image ("true").
nocache
bool
Do not use the build cache.
rm
bool
Remove intermediate containers after a successful build.
buildargs
&HashMap<&str, &str>
Build arguments (ARG values).
labels
&HashMap<&str, &str>
Labels to apply to the built image.
target
&str
Multi-stage target to build.
version
BuilderVersion
BuilderBuildKit for BuildKit, BuilderV1 (default) for legacy builder.
session
Option<String>
Session ID required when version = BuilderBuildKit.
Exports a single image as an uncompressed TAR archive. The archive contains a manifest.json, a repositories file, and layer subdirectories.Returns:impl Stream<Item = Result<Bytes, Error>>
Loads a set of images from a tar archive body (BodyType). Use bollard::body_full(bytes) for in-memory data.Returns:impl Stream<Item = Result<BuildInfo, Error>>
Like import_image but accepts a Stream<Item = Result<Bytes, E>> directly, avoiding holding the entire archive in memory.Returns:impl Stream<Item = Result<BuildInfo, Error>>
use bollard::Docker;use bollard::query_parameters::CreateImageOptionsBuilder;use futures_util::TryStreamExt;#[tokio::main]async fn main() { let docker = Docker::connect_with_socket_defaults().unwrap(); let options = CreateImageOptionsBuilder::default() .from_image("alpine") .tag("3.19") .build(); docker .create_image(Some(options), None, None) .try_collect::<Vec<_>>() .await .unwrap(); println!("alpine:3.19 pulled successfully");}
Methods that accept Option<DockerCredentials> or Option<HashMap<String, DockerCredentials>> pass credentials in the X-Registry-Auth or X-Registry-Config request header respectively, base64url-encoded. The DockerCredentials struct supports username, password, server_address, and identitytoken.