pub struct Containers { /* private fields */ }
Expand description
Handle for Podman Containers.
Implementations§
Source§impl Containers
impl Containers
Source§impl Containers
impl Containers
Sourcepub async fn create(
&self,
opts: &ContainerCreateOpts,
) -> Result<ContainerCreateCreatedBody>
pub async fn create( &self, opts: &ContainerCreateOpts, ) -> Result<ContainerCreateCreatedBody>
Create a container with specified options.
Examples:
async {
use podman_api::Podman;
use podman_api::opts::ContainerCreateOpts;
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
if let Err(e) = podman
.containers()
.create(
&ContainerCreateOpts::builder()
.image("debian:11")
.command(
["/usr/bin/httpd"]
)
.env([
("app", "web"),
])
.build(),
)
.await
{
eprintln!("{}", e);
}
};
Sourcepub async fn list(&self, opts: &ContainerListOpts) -> Result<Vec<ListContainer>>
pub async fn list(&self, opts: &ContainerListOpts) -> Result<Vec<ListContainer>>
Returns a list of containers.
Examples:
async {
use podman_api::Podman;
use podman_api::opts::{ContainerListOpts, ContainerListFilter};
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
for container in podman
.containers()
.list(
&ContainerListOpts::builder()
.all(true)
.filter([ContainerListFilter::LabelKeyVal("app".into(), "web".into())])
.build(),
)
.await
.unwrap()
{
println!("{:?}", container);
}
};
Sourcepub async fn stats(
&self,
opts: &ContainerStatsOpts,
) -> Result<ContainerStats200Response>
pub async fn stats( &self, opts: &ContainerStatsOpts, ) -> Result<ContainerStats200Response>
Return a single resource usage statistics of one or more container. If not container is specified in the options, the statistics of all are returned.
Examples:
async {
use podman_api::Podman;
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
match podman.containers().stats(&Default::default()).await {
Ok(stats) => println!("{:?}", stats),
Err(e) => eprintln!("{}", e),
}
};
Sourcepub fn stats_stream(
&self,
opts: &ContainerStatsOpts,
) -> impl Stream<Item = Result<ContainerStats200Response>> + '_
pub fn stats_stream( &self, opts: &ContainerStatsOpts, ) -> impl Stream<Item = Result<ContainerStats200Response>> + '_
Return a stream of resource usage statistics of one or more container. If not container is specified in the options, the statistics of all are returned.
Examples:
use futures_util::StreamExt;
async {
use podman_api::Podman;
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
let containers = podman.containers();
let mut stats = containers
.stats_stream(&Default::default());
while let Some(chunk) = stats.next().await {
match chunk {
Ok(chunk) => println!("{:?}", chunk),
Err(e) => eprintln!("{}", e),
}
}
};
Sourcepub async fn list_mounted(&self) -> Result<Value>
pub async fn list_mounted(&self) -> Result<Value>
List all mounted containers mount points.
Examples:
async {
use podman_api::Podman;
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
match podman.containers().list_mounted().await {
Ok(mounts) => println!("{:?}", mounts),
Err(e) => eprintln!("{}", e),
}
};
Sourcepub async fn prune(
&self,
opts: &ContainerPruneOpts,
) -> Result<Vec<ContainersPruneReportLibpod>>
pub async fn prune( &self, opts: &ContainerPruneOpts, ) -> Result<Vec<ContainersPruneReportLibpod>>
Remove containers not in use.
Examples:
async {
use podman_api::Podman;
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
match podman.containers().prune(&Default::default()).await {
Ok(report) => println!("{:?}", report),
Err(e) => eprintln!("{}", e),
}
};
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Containers
impl !RefUnwindSafe for Containers
impl Send for Containers
impl Sync for Containers
impl Unpin for Containers
impl !UnwindSafe for Containers
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