Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions,
see Getting Started with Amazon Web Services in China
(PDF).
Use ListImages
with an Amazon SDK or CLI
The following code examples show how to use ListImages
.
- CLI
-
- Amazon CLI
-
To list the images in a repository
The following list-images
example displays a list of the images in the cluster-autoscaler
repository.
aws ecr list-images \
--repository-name cluster-autoscaler
Output:
{
"imageIds": [
{
"imageDigest": "sha256:99c6fb4377e9a420a1eb3b410a951c9f464eff3b7dbc76c65e434e39b94b6570",
"imageTag": "v1.13.8"
},
{
"imageDigest": "sha256:99c6fb4377e9a420a1eb3b410a951c9f464eff3b7dbc76c65e434e39b94b6570",
"imageTag": "v1.13.7"
},
{
"imageDigest": "sha256:4a1c6567c38904384ebc64e35b7eeddd8451110c299e3368d2210066487d97e5",
"imageTag": "v1.13.6"
}
]
}
- Rust
-
- SDK for Rust
-
async fn show_images(
client: &aws_sdk_ecr::Client,
repository: &str,
) -> Result<(), aws_sdk_ecr::Error> {
let rsp = client
.list_images()
.repository_name(repository)
.send()
.await?;
let images = rsp.image_ids();
println!("found {} images", images.len());
for image in images {
println!(
"image: {}:{}",
image.image_tag().unwrap(),
image.image_digest().unwrap()
);
}
Ok(())
}
For a complete list of Amazon SDK developer guides and code examples, see
Using Amazon ECR with an Amazon SDK.
This topic also includes information about getting started and details about previous SDK versions.