pub struct ImagesCommand {
pub executor: CommandExecutor,
/* private fields */
}
Expand description
Docker Images Command Builder
Implements the docker images
command for listing local Docker images.
§Docker Images Overview
The images command lists Docker images stored locally on the system. It supports:
- Repository and tag filtering
- Multiple output formats (table, JSON, custom templates)
- Image metadata display (digests, sizes, creation dates)
- Advanced filtering by various criteria
- Quiet mode for scripts
§Image Information
Each image entry typically includes:
- Repository name
- Tag
- Image ID
- Creation date
- Size
- Optionally: digests, intermediate layers
§Examples
use docker_wrapper::ImagesCommand;
use docker_wrapper::DockerCommand;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// List all nginx images
let output = ImagesCommand::new()
.repository("nginx")
.execute()
.await?;
println!("Images success: {}", output.success());
Ok(())
}
Fields§
§executor: CommandExecutor
Command executor for handling raw arguments and execution
Implementations§
Source§impl ImagesCommand
impl ImagesCommand
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new ImagesCommand
instance
§Examples
use docker_wrapper::ImagesCommand;
let images_cmd = ImagesCommand::new();
Sourcepub fn repository<S: Into<String>>(self, repository: S) -> Self
pub fn repository<S: Into<String>>(self, repository: S) -> Self
Sourcepub fn all(self) -> Self
pub fn all(self) -> Self
Show all images (including intermediate images)
By default, Docker hides intermediate images. This option shows them all.
§Examples
use docker_wrapper::ImagesCommand;
let images_cmd = ImagesCommand::new()
.all();
Sourcepub fn digests(self) -> Self
pub fn digests(self) -> Self
Show digests
Displays the digest (SHA256 hash) for each image.
§Examples
use docker_wrapper::ImagesCommand;
let images_cmd = ImagesCommand::new()
.digests();
Sourcepub fn filter<S: Into<String>>(self, filter: S) -> Self
pub fn filter<S: Into<String>>(self, filter: S) -> Self
Add a filter condition
Common filters:
dangling=true|false
- Show dangling imageslabel=<key>
orlabel=<key>=<value>
- Filter by labelbefore=<image>
- Images created before this imagesince=<image>
- Images created since this imagereference=<pattern>
- Filter by repository name pattern
§Examples
use docker_wrapper::ImagesCommand;
let images_cmd = ImagesCommand::new()
.filter("dangling=true")
.filter("label=maintainer=nginx");
Sourcepub fn filters<I, S>(self, filters: I) -> Self
pub fn filters<I, S>(self, filters: I) -> Self
Add multiple filter conditions
§Examples
use docker_wrapper::ImagesCommand;
let images_cmd = ImagesCommand::new()
.filters(vec!["dangling=false", "label=version=latest"]);
Sourcepub fn format<S: Into<String>>(self, format: S) -> Self
pub fn format<S: Into<String>>(self, format: S) -> Self
Set custom output format
§Examples
use docker_wrapper::ImagesCommand;
let images_cmd = ImagesCommand::new()
.format("table {{.Repository}}:{{.Tag}}\t{{.Size}}");
Sourcepub fn format_table(self) -> Self
pub fn format_table(self) -> Self
Format output as table (default)
§Examples
use docker_wrapper::ImagesCommand;
let images_cmd = ImagesCommand::new()
.format_table();
Sourcepub fn format_json(self) -> Self
pub fn format_json(self) -> Self
Format output as JSON
§Examples
use docker_wrapper::ImagesCommand;
let images_cmd = ImagesCommand::new()
.format_json();
Sourcepub fn no_trunc(self) -> Self
pub fn no_trunc(self) -> Self
Don’t truncate output
By default, Docker truncates long values. This shows full values.
§Examples
use docker_wrapper::ImagesCommand;
let images_cmd = ImagesCommand::new()
.no_trunc();
Sourcepub fn quiet(self) -> Self
pub fn quiet(self) -> Self
Only show image IDs
Useful for scripting and automation.
§Examples
use docker_wrapper::ImagesCommand;
let images_cmd = ImagesCommand::new()
.quiet();
Sourcepub fn tree(self) -> Self
pub fn tree(self) -> Self
List multi-platform images as a tree (experimental)
This is an experimental Docker feature for displaying multi-platform images.
§Examples
use docker_wrapper::ImagesCommand;
let images_cmd = ImagesCommand::new()
.tree();
Sourcepub fn get_repository(&self) -> Option<&str>
pub fn get_repository(&self) -> Option<&str>
Get the repository filter if set
§Examples
use docker_wrapper::ImagesCommand;
let images_cmd = ImagesCommand::new().repository("nginx");
assert_eq!(images_cmd.get_repository(), Some("nginx"));
Sourcepub fn is_all(&self) -> bool
pub fn is_all(&self) -> bool
Check if showing all images
§Examples
use docker_wrapper::ImagesCommand;
let images_cmd = ImagesCommand::new().all();
assert!(images_cmd.is_all());
Sourcepub fn is_digests(&self) -> bool
pub fn is_digests(&self) -> bool
Check if showing digests
§Examples
use docker_wrapper::ImagesCommand;
let images_cmd = ImagesCommand::new().digests();
assert!(images_cmd.is_digests());
Sourcepub fn is_quiet(&self) -> bool
pub fn is_quiet(&self) -> bool
Check if quiet mode is enabled
§Examples
use docker_wrapper::ImagesCommand;
let images_cmd = ImagesCommand::new().quiet();
assert!(images_cmd.is_quiet());
Sourcepub fn is_no_trunc(&self) -> bool
pub fn is_no_trunc(&self) -> bool
Check if no-trunc is enabled
§Examples
use docker_wrapper::ImagesCommand;
let images_cmd = ImagesCommand::new().no_trunc();
assert!(images_cmd.is_no_trunc());
Sourcepub fn is_tree(&self) -> bool
pub fn is_tree(&self) -> bool
Check if tree mode is enabled
§Examples
use docker_wrapper::ImagesCommand;
let images_cmd = ImagesCommand::new().tree();
assert!(images_cmd.is_tree());
Sourcepub fn get_filters(&self) -> &[String]
pub fn get_filters(&self) -> &[String]
Get the current filters
§Examples
use docker_wrapper::ImagesCommand;
let images_cmd = ImagesCommand::new()
.filter("dangling=true");
assert_eq!(images_cmd.get_filters(), &["dangling=true"]);
Sourcepub fn get_format(&self) -> Option<&str>
pub fn get_format(&self) -> Option<&str>
Get the format if set
§Examples
use docker_wrapper::ImagesCommand;
let images_cmd = ImagesCommand::new().format_json();
assert_eq!(images_cmd.get_format(), Some("json"));
Sourcepub fn get_executor(&self) -> &CommandExecutor
pub fn get_executor(&self) -> &CommandExecutor
Get a reference to the command executor
Sourcepub fn get_executor_mut(&mut self) -> &mut CommandExecutor
pub fn get_executor_mut(&mut self) -> &mut CommandExecutor
Get a mutable reference to the command executor
Trait Implementations§
Source§impl Clone for ImagesCommand
impl Clone for ImagesCommand
Source§fn clone(&self) -> ImagesCommand
fn clone(&self) -> ImagesCommand
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more