How to list images in Docker?

Docker provides comprehensive commands to manage Docker objects including images, containers, volumes, and networks. When working with Docker extensively, you may accumulate numerous images on your system. Listing and managing these images efficiently becomes crucial for system organization and resource management.

This article explores various methods to list Docker images using different commands and options to filter, format, and display image information according to your specific requirements.

Basic Docker Image Listing Commands

Docker provides two primary commands for listing images, both yielding identical results:

docker image ls [OPTIONS] [REPOSITORY[:TAG]]
docker images [OPTIONS] [REPOSITORY[:TAG]]

Both commands accept the same options and provide equivalent functionality. The docker images command is a legacy shorthand that remains widely used.

Command Options

The following options can be used with both commands to customize output:

Option Description
--all Show all images including intermediate layers
--digests Display image digests alongside other information
--filter Filter output based on provided conditions
--format Format output using Go template syntax
--no-trunc Display full image IDs without truncation
--quiet Display only image IDs

Examples

Listing Images by Repository

To display images from a specific repository:

docker images nginx

To list images with specific tags:

docker images nginx:latest

Displaying Full Image IDs

By default, Docker truncates image IDs. Use --no-trunc to display complete IDs:

docker images --no-trunc

Including Image Digests

Image digests are unique identifiers for tagged images, useful for verifying image integrity:

docker images --digests

Filtering Images

The --filter option accepts key-value pairs to narrow down results. Common filters include:

Dangling Images

docker images --filter "dangling=true"

Images Created Before/After Another Image

docker images --filter "before=fedora"
docker images --filter "since=fedora"

Pattern Matching with Reference

docker images --filter=reference='m*'

Output Formatting

Quiet Mode

Display only image IDs for scripting purposes:

docker images --quiet

Custom Formatting

Use Go template syntax for custom output formats:

docker images --format "Image: {{.Repository}}:{{.Tag}} Size: {{.Size}}"

Available template placeholders include: .Repository, .Tag, .ID, .Digest, .CreatedAt, .CreatedSince, and .Size.

Listing All Images

To display all images including intermediate layers and dangling images:

docker images --all

Conclusion

Docker provides flexible commands for listing and filtering images based on various criteria. Understanding these options helps maintain organized Docker environments and efficiently locate specific images. The combination of filtering, formatting, and display options ensures you can retrieve exactly the image information needed for your workflow.

Updated on: 2026-03-17T09:01:38+05:30

7K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements