pub struct DockerCliRunner { /* private fields */ }Expand description
Docker CLI runner bound to a Unix socket.
Implementations§
Source§impl DockerCliRunner
impl DockerCliRunner
Sourcepub fn new(socket_path: impl Into<PathBuf>) -> Result<Self>
pub fn new(socket_path: impl Into<PathBuf>) -> Result<Self>
Creates a new CLI runner for the provided Docker socket.
§Errors
Returns an error if the docker binary cannot be located.
Sourcepub fn socket_path(&self) -> &Path
pub fn socket_path(&self) -> &Path
Returns the socket path used by this runner.
Sourcepub const fn helper_image_reference(&self) -> &'static str
pub const fn helper_image_reference(&self) -> &'static str
Returns the helper image reference used for temporary volume containers.
Sourcepub async fn info(&self) -> Result<DockerInfo>
pub async fn info(&self) -> Result<DockerInfo>
Returns Docker daemon info.
Sourcepub async fn list_images(&self) -> Result<Vec<ImageInspect>>
pub async fn list_images(&self) -> Result<Vec<ImageInspect>>
Returns all image inspect payloads.
Sourcepub async fn list_volumes(&self) -> Result<Vec<VolumeInspect>>
pub async fn list_volumes(&self) -> Result<Vec<VolumeInspect>>
Returns all volume inspect payloads.
Sourcepub async fn list_networks(&self) -> Result<Vec<NetworkInspect>>
pub async fn list_networks(&self) -> Result<Vec<NetworkInspect>>
Returns all user-defined network inspect payloads.
Sourcepub async fn list_containers(&self) -> Result<Vec<ContainerInspect>>
pub async fn list_containers(&self) -> Result<Vec<ContainerInspect>>
Returns all container inspect payloads, including stopped containers.
Sourcepub async fn stop_container(&self, id: &str) -> Result<()>
pub async fn stop_container(&self, id: &str) -> Result<()>
Stops a container.
Sourcepub async fn start_container(&self, id: &str) -> Result<()>
pub async fn start_container(&self, id: &str) -> Result<()>
Starts a container.
Sourcepub async fn remove_container(&self, id: &str) -> Result<()>
pub async fn remove_container(&self, id: &str) -> Result<()>
Removes a container forcibly.
Sourcepub async fn remove_stale_helper(&self, name: &str) -> Result<()>
pub async fn remove_stale_helper(&self, name: &str) -> Result<()>
Clears a helper container left behind by an interrupted run.
A run whose daemon died mid-copy strands its helper, and
docker create --name refuses a duplicate — which would wedge the retry
the user is certain to attempt, since a failed migration leaves them no
other way to get their data across. Clearing the name first makes the
volume copy idempotent.
Existence is checked rather than the removal being forced blindly, so a
genuine removal failure still surfaces instead of being swallowed as
“nothing was there”. remove_container passes --volumes, which reaps
only anonymous volumes, so the named volume being migrated is never at
risk.
Sourcepub async fn remove_volume(&self, name: &str) -> Result<()>
pub async fn remove_volume(&self, name: &str) -> Result<()>
Removes a volume.
Sourcepub async fn remove_network(&self, name: &str) -> Result<()>
pub async fn remove_network(&self, name: &str) -> Result<()>
Removes a network.
Sourcepub async fn create_volume(
&self,
name: &str,
labels: &[(String, String)],
options: &[(String, String)],
) -> Result<()>
pub async fn create_volume( &self, name: &str, labels: &[(String, String)], options: &[(String, String)], ) -> Result<()>
Creates a volume with labels and options.
Sourcepub async fn create_network(
&self,
name: &str,
config: &CreateNetworkOptions,
) -> Result<()>
pub async fn create_network( &self, name: &str, config: &CreateNetworkOptions, ) -> Result<()>
Creates a network using supported bridge-network flags.
Sourcepub async fn create_container<I, S>(&self, args: I) -> Result<String>
pub async fn create_container<I, S>(&self, args: I) -> Result<String>
Creates a container and returns its ID.
Sourcepub async fn connect_network(
&self,
network: &str,
container: &str,
aliases: &[String],
) -> Result<()>
pub async fn connect_network( &self, network: &str, container: &str, aliases: &[String], ) -> Result<()>
Connects a container to an additional network.
Sourcepub async fn create_helper_container(
&self,
name: &str,
volume_name: &str,
) -> Result<String>
pub async fn create_helper_container( &self, name: &str, volume_name: &str, ) -> Result<String>
Creates a helper container mounting the provided volume at /volume.
Sourcepub async fn ensure_helper_image(&self) -> Result<()>
pub async fn ensure_helper_image(&self) -> Result<()>
Ensures the helper image exists by importing an empty tar archive when needed.
Sourcepub async fn pipe_save_into(
&self,
target: &Self,
references: &[String],
) -> Result<ImageTransfer>
pub async fn pipe_save_into( &self, target: &Self, references: &[String], ) -> Result<ImageTransfer>
Streams docker save on this daemon straight into docker load on
target.
references must list every tag to preserve: docker save keeps all
tags of an image only for arguments given without a tag, so naming a
single repo:tag silently drops that image’s other tags.
Sourcepub async fn copy_from_container(
&self,
container: &str,
source_path: &str,
) -> Result<NamedTempFile>
pub async fn copy_from_container( &self, container: &str, source_path: &str, ) -> Result<NamedTempFile>
Streams a container path into a tempfile via docker cp.
--archive asks for source ownership explicitly. Note it is belt and
braces here, not a fix: the - stream forms already round-trip uid/gid
(measured 2026-08-01 — a 1000:1000 volume file survived a migration
on a build without this flag). The documented “ownership is set at the
destination” rule applies to path-to-path copies, not to tar streams.
Sourcepub async fn copy_to_container(
&self,
source_archive: &Path,
container: &str,
target_path: &str,
) -> Result<()>
pub async fn copy_to_container( &self, source_archive: &Path, container: &str, target_path: &str, ) -> Result<()>
Streams a tar archive tempfile into a container via docker cp.
See Self::copy_from_container for what --archive does and does
not buy here.
Trait Implementations§
Source§impl Clone for DockerCliRunner
impl Clone for DockerCliRunner
Source§fn clone(&self) -> DockerCliRunner
fn clone(&self) -> DockerCliRunner
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more