[−][src]Struct docker_client::client::DockerClient
DockerClient
struct.
Methods
impl DockerClient
[src]
pub fn connect<T>(path: T) -> DockerClient where
T: Into<String>,
[src]
T: Into<String>,
impl DockerClient
[src]
pub fn create_container(
&self,
config: Config
) -> Result<CreatedContainer, DockerError>
[src]
&self,
config: Config
) -> Result<CreatedContainer, DockerError>
Create a container
Arguments
Config
is container to create.
Examples
use docker_client::DockerClient; use docker_client::container::Config; fn main() { let client = DockerClient::connect("/var/run/docker.sock"); let config = Config::with_image("alpine").name("test").build(); match client.create_container(config) { Ok(_) => {}, Err(_) => {} } }
pub fn get_fs_changes<T>(&self, id: T) -> Result<Vec<FSChanges>, DockerError> where
T: Into<String>,
[src]
T: Into<String>,
Returns which files in a container's filesystem have been added, deleted, or modified.
Arguments
id
- ID or name of the container.
Examples
use docker_client::DockerClient; fn main() { let client = DockerClient::connect("/var/run/docker.sock"); let changes = client.get_fs_changes("test").unwrap_or(Vec::new()); for change in &changes { println!("{:?}", change); } }
pub fn start_container<T>(
&self,
id: T,
_detach_keys: T
) -> Result<(), DockerError> where
T: Into<String>,
[src]
&self,
id: T,
_detach_keys: T
) -> Result<(), DockerError> where
T: Into<String>,
Start a container.
Arguments
id
- ID or name of the container.detach_keys
- The key sequence for detaching a container.
Examples
use docker_client::{DockerClient, DockerError}; fn main() { let client = DockerClient::connect("/var/run/docker.sock"); match client.start_container("test", "-d") { Ok(_) => {}, Err(e) => { match e { DockerError::NotFound(e) => println!("{}", e.message), DockerError::ServerError(e) => println!("{}", e.message), _ => {} } }, } }
pub fn stop_container<T>(
&self,
id: T,
_wait: Option<i32>
) -> Result<(), DockerError> where
T: Into<String>,
[src]
&self,
id: T,
_wait: Option<i32>
) -> Result<(), DockerError> where
T: Into<String>,
Stop a container.
Arguments
id
- ID or name of the container.wait
- Number of seconds to wait before killing the container.
Examples
use docker_client::{DockerClient, DockerError}; fn main() { let client = DockerClient::connect("/var/run/docker.sock"); match client.stop_container("test", Some(12)) { Ok(_) => {}, Err(e) => { match e { DockerError::NotFound(e) => println!("{}", e.message), DockerError::ServerError(e) => println!("{}", e.message), _ => {} } }, } }
pub fn pause_container<T>(&self, id: T) -> Result<(), DockerError> where
T: Into<String>,
[src]
T: Into<String>,
Pause a container.
Arguments
id
- ID or name of the container.
Examples
use docker_client::{DockerClient, DockerError}; fn main() { let client = DockerClient::connect("/var/run/docker.sock"); match client.pause_container("test") { Ok(_) => {}, Err(e) => { match e { DockerError::NotFound(e) => println!("{}", e.message), DockerError::ServerError(e) => println!("{}", e.message), _ => {} } }, } }
pub fn unpause_container<T>(&self, id: T) -> Result<(), DockerError> where
T: Into<String>,
[src]
T: Into<String>,
Unpause a container.
Arguments
id
- ID or name of the container.
Examples
use docker_client::{DockerClient, DockerError}; fn main() { let client = DockerClient::connect("/var/run/docker.sock"); match client.unpause_container("test") { Ok(_) => {}, Err(e) => { match e { DockerError::NotFound(e) => println!("{}", e.message), DockerError::ServerError(e) => println!("{}", e.message), _ => {} } }, } }
pub fn rename_container<T>(&self, id: T, new_name: T) -> Result<(), DockerError> where
T: Into<String>,
[src]
T: Into<String>,
Rename a container.
Arguments
id
- ID or name of the container.new_name
- New name for the container.
Examples
use docker_client::{DockerClient, DockerError}; fn main() { let client = DockerClient::connect("/var/run/docker.sock"); match client.rename_container("test", "test1") { Ok(_) => {}, Err(e) => { match e { DockerError::NotFound(e) => println!("{}", e.message), DockerError::ContainerExists(e) => println!("{}", e.message), DockerError::ServerError(e) => println!("{}", e.message), _ => {} } }, } }
pub fn kill_container(&self, killer: Killer) -> Result<(), DockerError>
[src]
Kill a container.
Arguments
killer
is a struct with metadata to kill a container.
Examples
use docker_client::{DockerClient, DockerError}; use docker_client::container::Killer; fn main() { let client = DockerClient::connect("/var/run/docker.sock"); let killer = Killer::new() .id("test") .build(); match client.kill_container(killer) { Ok(_) => {} Err(e) => { match e { DockerError::NotFound(e) => println!("{}", e.message), DockerError::NotRunning(e) => println!("{}", e.message), DockerError::ServerError(e) => println!("{}", e.message), _ => {} } } } }
pub fn remove_container(&self, remover: Remover) -> Result<(), DockerError>
[src]
Remove a container.
Arguments
remover
is a struct with metadata to remove a container.
Examples
use docker_client::{DockerClient, DockerError}; use docker_client::container::Remover; fn main() { let client = DockerClient::connect("/var/run/docker.sock"); let remover = Remover::new() .id("test") .with_remove_volumes(true) .build(); match client.remove_container(remover) { Ok(_) => {} Err(e) => { match e { DockerError::BadParameters(e) => println!("{}", e.message), DockerError::NotFound(e) => println!("{}", e.message), DockerError::NotRunning(e) => println!("{}", e.message), DockerError::ServerError(e) => println!("{}", e.message), _ => {} } } } }
pub fn inspect_container<T>(
&self,
id: T,
size: bool
) -> Result<ContainerInfo, DockerError> where
T: Into<String>,
[src]
&self,
id: T,
size: bool
) -> Result<ContainerInfo, DockerError> where
T: Into<String>,
Inspect a container.
Return ContainerInfo
structure about a container.
Arguments
id
- ID or name of the container.size
- Return the size of container as fields SizeRw and SizeRootFs.
Examples
use docker_client::{DockerClient, DockerError}; fn main() { let client = DockerClient::connect("/var/run/docker.sock"); match client.inspect_container("test", true) { Ok(s) => { println!("{:?}", s) }, Err(e) => {}, } }
pub fn get_container_log<T>(&self, id: T) -> Result<String, DockerError> where
T: Into<String>,
[src]
T: Into<String>,
Get container logs
Get stdout and stderr logs from a container.
Note
This endpoint works only for containers with the json-file or journald logging driver.
Arguments
id
- ID or name of the container.
Examples
fn main() { let client = DockerClient::connect("/var/run/docker.sock"); match client.get_container_log("test-container") { Ok(log) => { println!("Log: {}", log); } Err(e) => { println!("Error: {:?}", e); } } }
pub fn wait_container<T>(
&self,
id: T,
condition: WaitCondition
) -> Result<WaitStatus, DockerError> where
T: Into<String>,
[src]
&self,
id: T,
condition: WaitCondition
) -> Result<WaitStatus, DockerError> where
T: Into<String>,
Wait for a container
Block until a container stops, then returns the exit code.
Arguments
id
- ID or name of the container.
condition
- Wait until a container state reaches the given condition, either 'not-running' (default), 'next-exit', or 'removed'.
Examples
fn main() { let client = DockerClient::connect("/var/run/docker.sock"); match client.wait_container("test-container", WaitCondition::NotRunning) { Ok(status) => { println!("Status: {:?}", status); } Err(e) => { println!("Error: {:?}", e); } } }
pub fn export_container<T>(&self, id: T) -> Result<(), DockerError> where
T: Into<String>,
[src]
T: Into<String>,
Export a container
Return empty object or DockerError
Arguments
id
- ID or name of the container.
Examples
fn main() { let client = DockerClient::connect("/var/run/docker.sock"); match client.export_container("test-container") { Ok(_) => {}, Err(e) => { println!("Error: {:?}", e); }, } }
pub fn get_image_list(&self) -> Result<Vec<ShortImageInfo>, DockerError>
[src]
Get images list
Return vector of ShortImageInfo or DockerError
Examples
fn main() { let client = DockerClient::connect("/var/run/docker.sock"); match client.get_image_list() { Ok(list) => { println!("{:?}", list); }, Err(e) => { println!("Error: {:?}", e); }, } }
pub fn create_volume(&self, volume: VolumeCreator) -> Result<(), DockerError>
[src]
Create a volume
Return empty object or DockerError
Arguments
volume
- VolumeCreator struct.
Examples
fn main() { let client = DockerClient::connect("/var/run/docker.sock"); let creator = VolumeCreator::builder() .name("test") .build(); match client.create_volume(creator) { Ok(_) => {}, Err(e) => { println!("Error: {:?}", e); }, } }
pub fn inspect_volume<T>(&self, name: T) -> Result<VolumeInfo, DockerError> where
T: Into<String>,
[src]
T: Into<String>,
Inspect volume
Return VolumeInfo or DockerError
Arguments
name
- ID or name of the volume.
Examples
fn main() { let client = DockerClient::connect("/var/run/docker.sock"); match client.inspect_volume("test") { Ok(info) => { println!("{:?}", info); }, Err(e) => { println!("Error: {:?}", e); }, } }
pub fn remove_volume<T>(&self, name: T, force: bool) -> Result<(), DockerError> where
T: Into<String>,
[src]
T: Into<String>,
Remove volume
Instruct the driver to remove the volume.
Arguments
name
- ID or name of the volume.force
- Force the removal of the volume.
Examples
fn main() { let client = DockerClient::connect("/var/run/docker.sock"); match client.remove_volume("test", false) { Ok(_) => {}, Err(e) => { println!("Error: {:?}", e); }, } }
pub fn delete_unused_volumes(&self) -> Result<DeletedInfo, DockerError>
[src]
Delete unused volumes
Return empty or DockerError
Examples
fn main() { let client = DockerClient::connect("/var/run/docker.sock"); match client.delete_unused_volumes() { Ok(_) => {}, Err(e) => { println!("Error: {:?}", e); }, } }
pub fn get_volumes_list(&self) -> Result<VolumesList, DockerError>
[src]
Get volumes list
Return VolumesList or DockerError
Examples
fn main() { let client = DockerClient::connect("/var/run/docker.sock"); match client.get_volumes_list() { Ok(list) => { println!("{:?}", list); }, Err(e) => { println!("Error: {:?}", e); }, } }
Trait Implementations
Auto Trait Implementations
impl Send for DockerClient
impl Sync for DockerClient
impl Unpin for DockerClient
impl !UnwindSafe for DockerClient
impl !RefUnwindSafe for DockerClient
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,