[−][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) => {}, } }
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,