Struct podman_api::api::Images
source · [−]pub struct Images<'podman> { /* private fields */ }
Expand description
Handle for Podman Images.
Implementations
sourceimpl<'podman> Images<'podman>
impl<'podman> Images<'podman>
sourcepub async fn build(
&self,
opts: &ImageBuildOpts
) -> Result<LibpodImageBuildResponse>
pub async fn build(
&self,
opts: &ImageBuildOpts
) -> Result<LibpodImageBuildResponse>
Build an image from the given Dockerfile(s)
Examples:
async {
use podman_api::Podman;
use podman_api::opts::ImageBuildOpts;
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
if let Err(e) = podman
.images()
.build(
&ImageBuildOpts::builder()
.remote("http://some.url.to/Dockerfile")
.tag("myimage:1.0.0")
.build(),
)
.await
{
eprintln!("{}", e);
}
};
sourcepub async fn list(
&self,
opts: &ImageListOpts
) -> Result<Vec<LibpodImageSummary>>
pub async fn list(
&self,
opts: &ImageListOpts
) -> Result<Vec<LibpodImageSummary>>
Returns a list of images.
Examples:
async {
use podman_api::Podman;
use podman_api::opts::{ImageListOpts, ImageListFilter};
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
for image in podman
.images()
.list(
&ImageListOpts::builder()
.all(true)
.filter([ImageListFilter::Dangling(true)])
.build(),
)
.await
.unwrap()
{
println!("{:?}", image);
}
};
sourcepub async fn pull(&self, opts: &PullOpts) -> Result<LibpodImagesPullReport>
pub async fn pull(&self, opts: &PullOpts) -> Result<LibpodImagesPullReport>
Pull one or more images from a container registry.
Examples:
async {
use podman_api::Podman;
use podman_api::opts::PullOpts;
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
if let Err(e) = podman
.images()
.pull(
&PullOpts::builder()
.reference("rockylinux/rockylinux:8")
.build(),
)
.await
{
eprintln!("{}", e);
}
};
sourcepub async fn load(&self, image: impl AsRef<[u8]>) -> Result<ImageLoadReport>
pub async fn load(&self, image: impl AsRef<[u8]>) -> Result<ImageLoadReport>
Load an image (oci-archive or docker-archive) stream.
Examples:
async {
use podman_api::Podman;
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
let image = std::fs::read("image_archive").unwrap();
match podman.images().load(&image).await {
Ok(info) => println!("{:?}", info),
Err(e) => eprintln!("{}", e),
}
};
sourcepub async fn import(
&self,
opts: &ImageImportOpts,
image: impl AsRef<[u8]>
) -> Result<LibpodImagesPullReport>
pub async fn import(
&self,
opts: &ImageImportOpts,
image: impl AsRef<[u8]>
) -> Result<LibpodImagesPullReport>
Import a previously exported tarball as an image.
Examples:
async {
use podman_api::Podman;
use podman_api::opts::ImageImportOpts;
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
let image = vec![0, 1];
if let Err(e) = podman
.images()
.import(
&ImageImportOpts::builder()
.reference("rockylinux/rockylinux:8")
.build(),
image
)
.await
{
eprintln!("{}", e);
}
};
sourcepub async fn remove(
&self,
opts: &ImagesRemoveOpts
) -> Result<LibpodImagesRemoveReport>
pub async fn remove(
&self,
opts: &ImagesRemoveOpts
) -> Result<LibpodImagesRemoveReport>
Remove multiple images. To remove a single image use
Image::delete
or Image::remove
.
Examples:
async {
use podman_api::Podman;
use podman_api::opts::ImagesRemoveOpts;
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
match podman
.images()
.remove(&ImagesRemoveOpts::builder().all(true).force(true).build())
.await
{
Ok(info) => println!("{:?}", info),
Err(e) => eprintln!("{}", e),
}
};
sourcepub async fn prune(
&self,
opts: &ImagePruneOpts
) -> Result<Vec<ContainersPruneReport>>
pub async fn prune(
&self,
opts: &ImagePruneOpts
) -> Result<Vec<ContainersPruneReport>>
Remove images that are not being used by a container.
Examples:
async {
use podman_api::Podman;
use podman_api::opts::ImagePruneOpts;
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
match podman
.images()
.prune(
&ImagePruneOpts::builder()
.all(true)
.build()
).await {
Ok(report) => println!("{:?}", report),
Err(e) => eprintln!("{}", e),
}
};
sourcepub async fn search(
&self,
opts: &ImageSearchOpts
) -> Result<Vec<LibpodImageSearchResponse>>
pub async fn search(
&self,
opts: &ImageSearchOpts
) -> Result<Vec<LibpodImageSearchResponse>>
Search registries for images.
Examples:
async {
use podman_api::Podman;
use podman_api::opts::ImageSearchOpts;
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
match podman
.images()
.search(
&ImageSearchOpts::builder()
.list_tags(true)
.build()
).await {
Ok(images) => println!("{:?}", images),
Err(e) => eprintln!("{}", e),
}
};
sourcepub async fn export(&self, opts: &ImagesExportOpts) -> Result<Vec<u8>>
pub async fn export(&self, opts: &ImagesExportOpts) -> Result<Vec<u8>>
Export multiple images into a single object.
Examples:
async {
use podman_api::Podman;
use podman_api::opts::ImagesExportOpts;
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
match podman
.images()
.export(
&ImagesExportOpts::builder()
.references(["alpine", "ubuntu"])
.build()
).await {
Ok(images) => { /* ... */ },
Err(e) => eprintln!("{}", e),
}
};
Trait Implementations
Auto Trait Implementations
impl<'podman> !RefUnwindSafe for Images<'podman>
impl<'podman> Send for Images<'podman>
impl<'podman> Sync for Images<'podman>
impl<'podman> Unpin for Images<'podman>
impl<'podman> !UnwindSafe for Images<'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