pub struct Image { /* private fields */ }
Expand description
Interface for accessing and manipulating Podman Image.
Implementations§
Source§impl Image
impl Image
Sourcepub async fn inspect(&self) -> Result<InspectImageResponseLibpod>
pub async fn inspect(&self) -> Result<InspectImageResponseLibpod>
Obtain low-level information about this image.
Examples:
async {
use podman_api::Podman;
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
match podman.images().get("debian").inspect().await {
Ok(info) => println!("{:?}", info),
Err(e) => eprintln!("{}", e),
}
};
Sourcepub async fn history(&self) -> Result<Vec<HistoryResponse>>
pub async fn history(&self) -> Result<Vec<HistoryResponse>>
Return parent layers of an image.
Examples:
async {
use podman_api::Podman;
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
match podman.images().get("debian").history().await {
Ok(info) => println!("{:?}", info),
Err(e) => eprintln!("{}", e),
}
};
Sourcepub async fn exists(&self) -> Result<bool>
pub async fn exists(&self) -> Result<bool>
Quick way to determine if a image exists by name or ID.
Examples:
async {
use podman_api::Podman;
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
match podman.images().get("debian").exists().await {
Ok(exists) => if exists {
println!("image exists!");
} else {
println!("image doesn't exists!");
},
Err(e) => eprintln!("check failed: {}", e),
}
};
Sourcepub async fn delete(&self) -> Result<()>
pub async fn delete(&self) -> Result<()>
Delete this image from local storage. To forcefully remove an image use
Image::remove
.
Examples:
async {
use podman_api::Podman;
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
if let Err(e) = podman.images().get("debian").delete().await {
eprintln!("{}", e);
}
};
Sourcepub async fn remove(&self) -> Result<()>
pub async fn remove(&self) -> Result<()>
Remove this image forcefully from local storage. To remove the image normally use
Image::delete
.
Examples:
async {
use podman_api::Podman;
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
if let Err(e) = podman.images().get("debian").remove().await {
eprintln!("{}", e);
}
};
Sourcepub async fn tag(&self, opts: &ImageTagOpts) -> Result<()>
pub async fn tag(&self, opts: &ImageTagOpts) -> Result<()>
Tag an image so that it becomes part of a repository.
Examples:
async {
use podman_api::Podman;
use podman_api::opts::ImageTagOpts;
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
if let Err(e) = podman
.images()
.get("debian")
.tag(
&ImageTagOpts::builder()
.repo("my.custom.repo/debian")
.tag("1.0.0")
.build(),
)
.await
{
eprintln!("{}", e);
}
};
Sourcepub async fn untag(&self, opts: &ImageTagOpts) -> Result<()>
pub async fn untag(&self, opts: &ImageTagOpts) -> Result<()>
Untag an image. If repo and tag are not specified, all tags are removed from the image.
Examples:
async {
use podman_api::Podman;
use podman_api::opts::ImageTagOpts;
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
if let Err(e) = podman
.images()
.get("debian")
.untag(
&ImageTagOpts::builder()
.repo("my.custom.repo/debian")
.tag("1.0.0")
.build(),
)
.await
{
eprintln!("{}", e);
}
};
Sourcepub fn export(
&self,
opts: &ImageExportOpts,
) -> impl Stream<Item = Result<Vec<u8>>> + Unpin + '_
pub fn export( &self, opts: &ImageExportOpts, ) -> impl Stream<Item = Result<Vec<u8>>> + Unpin + '_
Export this image.
Examples:
async {
use podman_api::Podman;
use futures_util::stream::TryStreamExt;
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
let image = podman.images().get("myimage");
let export_stream = image.export(&Default::default());
let export_data = export_stream.try_concat().await.expect("image archive");
assert!(!export_data.is_empty());
};
Sourcepub async fn changes(
&self,
opts: &ChangesOpts,
) -> Result<Vec<ContainerChangeResponseItem>>
pub async fn changes( &self, opts: &ChangesOpts, ) -> Result<Vec<ContainerChangeResponseItem>>
Returns which files in this image’s filesystem have been added, deleted, or modified.
Examples:
async {
use podman_api::Podman;
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
match podman
.images()
.get("79c93f220e3e")
.changes(&Default::default())
.await
{
Ok(changes) => println!("{:?}", changes),
Err(e) => eprintln!("{}", e),
}
};
Sourcepub async fn tree(&self, opts: &ImageTreeOpts) -> Result<TreeResponse>
pub async fn tree(&self, opts: &ImageTreeOpts) -> Result<TreeResponse>
Retrieve the image tree for this image.
Examples:
async {
use podman_api::Podman;
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
match podman
.images()
.get("79c93f220e3e")
.tree(&Default::default())
.await
{
Ok(tree) => println!("{:?}", tree),
Err(e) => eprintln!("{}", e),
}
};
Sourcepub async fn push(&self, opts: &ImagePushOpts) -> Result<String>
pub async fn push(&self, opts: &ImagePushOpts) -> Result<String>
Push this image to a container registry.
Examples:
async {
use podman_api::Podman;
use podman_api::opts::{RegistryAuth, ImagePushOpts};
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
match podman.images().get("alpine").push(
&ImagePushOpts::builder()
.destinations("my-destination")
.tls_verify(true)
.auth(
RegistryAuth::builder()
.username("test")
.password("test")
.server_address("https://my-registry")
.build(),
)
.build(),
).await {
Ok(s) => println!("{}", s),
Err(e) => eprintln!("{}", e),
};
};