Struct podman_api::api::Containers
source · [−]pub struct Containers<'podman> { /* private fields */ }
Expand description
Handle for Podman Containers.
Implementations
sourceimpl<'podman> Containers<'podman>
impl<'podman> Containers<'podman>
sourceimpl<'podman> Containers<'podman>
impl<'podman> Containers<'podman>
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<LibpodContainerStatsResponse>
pub async fn stats(
&self,
opts: &ContainerStatsOpts
) -> Result<LibpodContainerStatsResponse>
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<LibpodContainerStatsResponse>> + 'podman
pub fn stats_stream(
&self,
opts: &ContainerStatsOpts
) -> impl Stream<Item = Result<LibpodContainerStatsResponse>> + 'podman
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 mut stats = podman
.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<ContainersPruneReport>>
pub async fn prune(
&self,
opts: &ContainerPruneOpts
) -> Result<Vec<ContainersPruneReport>>
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<'podman> !RefUnwindSafe for Containers<'podman>
impl<'podman> Send for Containers<'podman>
impl<'podman> Sync for Containers<'podman>
impl<'podman> Unpin for Containers<'podman>
impl<'podman> !UnwindSafe for Containers<'podman>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more