Struct DockerClient

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

A structure defining a Client to interact with the docker API

  • unix_socket: UnixStream connection for docker socket.
  • protocol: Underlying protocol we are using(UNIX by default.)

Implementations§

Source§

impl DockerClient

Source

pub fn new( connection_addr: &'static str, ) -> Result<DockerClient, DockerClientError>

Creates a new DockerClient object connected to docker’s unix domain socket.

Trait Implementations§

Source§

impl Clone for DockerClient

Implement clone for the DockerClient structure. The clone here is not true clone, the unix_socket cloned still refers to the stream and change to one of the two will propogate the changes to other.

Source§

fn clone(&self) -> DockerClient

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Containers for DockerClient

Source§

fn get_response_from_api( &self, api_endpoint: &str, method: &str, body: &str, ) -> Result<Response, String>

Just a helper function for the Containers DockerApiClient. It formats the API request using the given parameters, and using this request the docker daemon and sends back the response of the request if the request was successful else an err.
Source§

fn get_containers( &self, api_endpoint: &str, method: &str, query_param: &str, ) -> Result<Vec<Container>, String>

Get Containers from the API endpoint with the method and query_param. Helper function for Container trait.
Source§

fn list_running_containers( &self, limit: Option<u32>, ) -> Result<Vec<Container>, String>

List all the running containers Return an instance of Vector of container Read more
Source§

fn list_all_containers( &self, limit: Option<u32>, ) -> Result<Vec<Container>, String>

List all containers whether running or stopped.
Source§

fn get_container_details_with_filter( &self, filter: &str, limit: Option<u32>, ) -> Result<Vec<Container>, String>

List container with the filter provided, the filter can be looked from Docker engine official API documentation. https://docs.docker.com/engine/api/v1.37/#operation/ContainerList
Source§

fn create_container( &self, name: &str, config: ContainerConfig, ) -> Result<CreateContainerResponse, String>

Create a container from the ContainerConfig structure with the provided name. The response for the request is the CreateContaierResponse struct which contains the ID for the container which we created.
Source§

fn create_container_minimal( &self, name: &str, image: &str, cmd: Vec<String>, ) -> Result<CreateContainerResponse, String>

Creates/Spawn docker container from the configuration provided. It only Read more
Source§

fn inspect_container(&self, id: &str) -> Result<ContainerDetails, String>

Inspects the container with the provided ID Returns Low level information about the container. Read more
Source§

fn get_container_filesystem_changes( &self, id: &str, ) -> Result<Vec<ContainerFsChange>, String>

Gives the changes done to somewhere in the filesystem in the docker container as a list of files with the kind of changes.
Source§

fn manipulate_container_status( &self, action: &str, id: &str, params: &str, ) -> Result<String, String>

Function to manipulate container status It is a parent function for all the commands which result in a status change of the container. Read more
Source§

fn start_container(&self, id: &str) -> Result<String, String>

Source§

fn stop_container( &self, id: &str, delay: Option<&str>, ) -> Result<String, String>

Source§

fn pause_container(&self, id: &str) -> Result<String, String>

Source§

fn unpause_container(&self, id: &str) -> Result<String, String>

Source§

fn restart_container( &self, id: &str, delay: Option<&str>, ) -> Result<String, String>

Source§

fn kill_container( &self, id: &str, signal: Option<&str>, ) -> Result<String, String>

Source§

fn rename_container(&self, id: &str, name: &str) -> Result<String, String>

Source§

impl DockerApiClient for DockerClient

Source§

fn request(&self, request: &str) -> Option<Vec<u8>>

Source§

impl Version for DockerClient

Source§

fn get_version_info(&self) -> Result<String, String>

Get version info for Docker Returns a JSON serialized string containing this information 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.