pub struct Containers<'a> { /* private fields */ }Expand description
Container operations manager.
Implementations§
Source§impl<'a> Containers<'a>
impl<'a> Containers<'a>
Sourcepub fn create(&self, image: impl Into<String>) -> ContainerBuilder<'a>
pub fn create(&self, image: impl Into<String>) -> ContainerBuilder<'a>
Create a new container builder.
§Example
use lmrc_docker::DockerClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = DockerClient::new()?;
let container = client.containers()
.create("nginx:latest")
.name("web-server")
.port(8080, 80, "tcp")
.env("ENV", "production")
.build()
.await?;
Ok(())
}Sourcepub fn get(&self, name_or_id: impl Into<String>) -> ContainerRef<'a>
pub fn get(&self, name_or_id: impl Into<String>) -> ContainerRef<'a>
Get a reference to a specific container.
Sourcepub async fn list(&self, all: bool) -> Result<Vec<ContainerSummary>>
pub async fn list(&self, all: bool) -> Result<Vec<ContainerSummary>>
List all containers.
§Example
use lmrc_docker::DockerClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = DockerClient::new()?;
let containers = client.containers().list(true).await?;
for container in containers {
println!("{:?}", container.names);
}
Ok(())
}Sourcepub async fn prune(&self) -> Result<ContainerPruneResponse>
pub async fn prune(&self) -> Result<ContainerPruneResponse>
Prune stopped containers.
Auto Trait Implementations§
impl<'a> Freeze for Containers<'a>
impl<'a> !RefUnwindSafe for Containers<'a>
impl<'a> Send for Containers<'a>
impl<'a> Sync for Containers<'a>
impl<'a> Unpin for Containers<'a>
impl<'a> !UnwindSafe for Containers<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more