Skip to main content

DockerCliRunner

Struct DockerCliRunner 

Source
pub struct DockerCliRunner { /* private fields */ }
Expand description

Docker CLI runner bound to a Unix socket.

Implementations§

Source§

impl DockerCliRunner

Source

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.

Source

pub fn socket_path(&self) -> &Path

Returns the socket path used by this runner.

Source

pub const fn helper_image_reference(&self) -> &'static str

Returns the helper image reference used for temporary volume containers.

Source

pub async fn info(&self) -> Result<DockerInfo>

Returns Docker daemon info.

Source

pub async fn list_images(&self) -> Result<Vec<ImageInspect>>

Returns all image inspect payloads.

Source

pub async fn list_volumes(&self) -> Result<Vec<VolumeInspect>>

Returns all volume inspect payloads.

Source

pub async fn list_networks(&self) -> Result<Vec<NetworkInspect>>

Returns all user-defined network inspect payloads.

Source

pub async fn list_containers(&self) -> Result<Vec<ContainerInspect>>

Returns all container inspect payloads, including stopped containers.

Source

pub async fn stop_container(&self, id: &str) -> Result<()>

Stops a container.

Source

pub async fn remove_container(&self, id: &str) -> Result<()>

Removes a container forcibly.

Source

pub async fn remove_volume(&self, name: &str) -> Result<()>

Removes a volume.

Source

pub async fn remove_network(&self, name: &str) -> Result<()>

Removes a network.

Source

pub async fn create_volume( &self, name: &str, labels: &[(String, String)], options: &[(String, String)], ) -> Result<()>

Creates a volume with labels and options.

Source

pub async fn create_network( &self, name: &str, config: &CreateNetworkOptions, ) -> Result<()>

Creates a network using supported bridge-network flags.

Source

pub async fn create_container<I, S>(&self, args: I) -> Result<String>
where I: IntoIterator<Item = S>, S: AsRef<str>,

Creates a container and returns its ID.

Source

pub async fn connect_network( &self, network: &str, container: &str, aliases: &[String], ) -> Result<()>

Connects a container to an additional network.

Source

pub async fn create_helper_container( &self, name: &str, volume_name: &str, ) -> Result<String>

Creates a helper container mounting the provided volume at /volume.

Source

pub async fn ensure_helper_image(&self) -> Result<()>

Ensures the helper image exists by importing an empty tar archive when needed.

Source

pub async fn save_image(&self, reference: &str) -> Result<NamedTempFile>

Saves an image to a tempfile.

Source

pub async fn load_image(&self, path: &Path) -> Result<()>

Loads an image from a tempfile.

Source

pub async fn copy_from_container( &self, container: &str, source_path: &str, ) -> Result<NamedTempFile>

Streams a container path into a tempfile via docker cp.

Source

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.

Trait Implementations§

Source§

impl Clone for DockerCliRunner

Source§

fn clone(&self) -> DockerCliRunner

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DockerCliRunner

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.