pub struct Images<'a> { /* private fields */ }Expand description
Image operations manager.
Implementations§
Source§impl<'a> Images<'a>
impl<'a> Images<'a>
Sourcepub fn build(&self, tag: impl Into<String>) -> ImageBuilder<'a>
pub fn build(&self, tag: impl Into<String>) -> ImageBuilder<'a>
Create a new image builder for building images.
§Example
use docker_client::DockerClient;
use std::path::Path;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = DockerClient::new()?;
client.images()
.build("my-app:latest")
.dockerfile("Dockerfile")
.context(Path::new("."))
.build_arg("RUNTIME_IMAGE", "alpine:latest")
.execute()
.await?;
Ok(())
}Sourcepub fn get(&self, name_or_id: impl Into<String>) -> ImageRef<'a>
pub fn get(&self, name_or_id: impl Into<String>) -> ImageRef<'a>
Get a reference to a specific image.
Sourcepub async fn list(&self, all: bool) -> Result<Vec<ImageSummary>>
pub async fn list(&self, all: bool) -> Result<Vec<ImageSummary>>
List all images.
§Example
use docker_client::DockerClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = DockerClient::new()?;
let images = client.images().list(true).await?;
for image in images {
println!("{:?}", image.repo_tags);
}
Ok(())
}Sourcepub async fn pull(
&self,
image: impl Into<String>,
credentials: Option<DockerCredentials>,
) -> Result<()>
pub async fn pull( &self, image: impl Into<String>, credentials: Option<DockerCredentials>, ) -> Result<()>
Pull an image from a registry.
§Arguments
image- Image name with optional tag (e.g., “nginx:latest”)credentials- Optional Docker registry credentials
§Example
use docker_client::DockerClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = DockerClient::new()?;
client.images().pull("nginx:latest", None).await?;
Ok(())
}Sourcepub async fn search(
&self,
term: impl Into<String>,
limit: Option<i64>,
) -> Result<Vec<ImageSearchResponseItem>>
pub async fn search( &self, term: impl Into<String>, limit: Option<i64>, ) -> Result<Vec<ImageSearchResponseItem>>
Search for images in a registry.
§Example
use docker_client::DockerClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = DockerClient::new()?;
let results = client.images().search("nginx", None).await?;
for result in results {
println!("{}: {}", result.name, result.description);
}
Ok(())
}Auto Trait Implementations§
impl<'a> Freeze for Images<'a>
impl<'a> !RefUnwindSafe for Images<'a>
impl<'a> Send for Images<'a>
impl<'a> Sync for Images<'a>
impl<'a> Unpin for Images<'a>
impl<'a> !UnwindSafe for Images<'a>
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