pub struct Containers<'podman> { /* private fields */ }
Expand description

Handle for Podman Containers.

Implementations

Exports an interface for interacting with Podman Containers.

Returns a reference to a set of operations available to a specific Container.

Api Reference

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);
    }
};

Api Reference

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);
    }
};

Api Reference

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),
    }
};

Api Reference

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),
        }
    }
};

Api Reference

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),
    }
};

Api Reference

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

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more