Aws / List Images In Repository
List Images In Repository
Lists all images in a specified ECR repository along with their details.
aws ecr list-images --repository-name <repository> aws ecr list-images --repository-name <repository> #!/bin/bash
# List Images In Repository
aws ecr list-images --repository-name {{repository}} import subprocess
# List Images In Repository
# Make sure to replace <placeholders> with actual values
def run_command():
cmd = [
"aws",
"ecr",
"list-images",
"--repository-name",
"<repository>"
]
try:
print(f"Executing: {' '.join(cmd)}")
subprocess.run(cmd, check=True)
except subprocess.CalledProcessError as e:
print(f"Error: {e}")
except FileNotFoundError:
print("Error: aws not found. Please install it first.")
if __name__ == "__main__":
run_command() When To Use
When conducting audits or evaluations of containerization strategy and image usage.
Pro Tip
Pipe the output through `jq` for easier readability and customization of output format.
Command Builder
Tune the command before you copy it
aws ecr list-images --repository-name <repository> Terminal Output
Expected runtime feedback
{
"imageIds": [
{
"imageDigest": "sha256:abc123...",
"imageTag": "latest"
},
{
"imageDigest": "sha256:def456...",
"imageTag": "v1.0"
}
],
"nextToken": null
} Anatomy of Output
Understanding the result
{ "imageDetails": [ { "imageDigest": "sha256:abc123...", "imageTag": "latest", "imagePushedAt": "2021-01-01T10:00:00Z", "imageSizeInBytes": 2048 } ] } Image Details Output Lists the image digest, tag, pushing date, and size for each image.
{ "failures": [] } Operation Summary Confirms whether or not the operation encountered any failures.
Troubleshooting
Common pitfalls
An error occurred (RepositoryNotFoundException) when calling the ListImages operation: The specified repository does not exist.
Solution: Ensure the repository name is correct.
An error occurred (UnauthorizedException) when calling the ListImages operation: User is not authorized to perform this operation.
Solution: Check the IAM permissions for ListImages on the ECR.
An error occurred (InvalidParameterException) when calling the ListImages operation: Invalid parameter specified.
Solution: Verify that the repository name is correctly formatted.
Command Breakdown
What each part is doing
-
aws - Base Command
- The executable that performs this operation. Here it runs Aws before the shell applies any redirect operators.
-
<repository> - repository
- The value supplied for repository.
-
--repository-name - Command Option
- Tool-specific option used by this command invocation.
How To Run
Execution path
- Step 1
Run the command: aws ecr list-images --repository-name my-repo
- Step 2
Verify the output for image details and tags.
Alternative Approaches
Comparable commands in other tools
Alternative containers tools for the same job.
az acr repository list -n <registry_name> --output table Colima / List Containers Status colima list Crane / Set Address To Listen On crane registry serve --address <address_name> Systemd Dissect / Show Image Information Linux systemd-dissect <path/to/image.raw> Systemd Dissect / List Files In Image Linux systemd-dissect -l <path/to/image.raw>