LinuxCommandLibrary

docker-images

List available Docker images

TLDR

List all Docker images

$ docker images
copy

List all Docker images including intermediates
$ docker images [[-a|--all]]
copy

List the output in quiet mode (only numeric IDs)
$ docker images [[-q|--quiet]]
copy

List all Docker images not used by any container
$ docker images [[-f|--filter]] dangling=true
copy

List images that contain a substring in their name
$ docker images "[*name*]"
copy

Sort images by size
$ docker images --format "\{\{.ID\}\}\t\{\{.Size\}\}\t\{\{.Repository\}\}:\{\{.Tag\}\}" | sort [[-k|--key]] 2 [[-h|--human-numeric-sort]]
copy

SYNOPSIS

docker images [OPTIONS] [REPOSITORY[:TAG]]
The [REPOSITORY[:TAG]] part is an optional positional argument used to filter images by a specific repository name and/or tag.

PARAMETERS

-a, --all
    Show all images, including intermediate layers. By default, only top-level images are displayed.

--digests
    Show image digests (SHA256 checksums) in the output.

-f, --filter filter
    Filter output based on various conditions. Common filters include 'dangling=true' (for untagged images), 'label==', 'reference=', 'before=', 'since=', 'size=', etc.

--format string
    Pretty-print images using a Go template, allowing customized output. For example: '{{.ID}}\t{{.Repository}}\t{{.Size}}'.

--no-trunc
    Do not truncate output. Image IDs and other fields will be displayed in full.

-q, --quiet
    Only display numeric IDs (Image IDs) of the images, suppressing all other columns.

DESCRIPTION

The docker images command (also accessible as docker image ls) is a fundamental Docker CLI utility used to list Docker images available on the local system. It provides a comprehensive overview of images, including their repository name, tag, unique image ID, the date and time they were created, and their virtual size. This command is essential for managing your local image cache, identifying images to be removed, verifying successful image builds, or simply inspecting what images you have downloaded or created. It displays both top-level images and optionally, all intermediate image layers.

CAVEATS

Images consume significant disk space; regularly inspect and remove unused images using docker rmi or docker prune. Dangling images (untagged images not referenced by any container) can accumulate and waste space. They can be found using docker images -f "dangling=true" and removed with docker rmi $(docker images -f "dangling=true" -q) or more easily with docker image prune.

FILTERING EXAMPLES

To show only dangling images: docker images -f "dangling=true"
To show images larger than 1GB: docker images -f "size=1G"
To show images by a specific label: docker images -f "label=version=1.0"

CUSTOM OUTPUT FORMATTING

Using --format allows precise control over the output columns and their presentation, useful for scripting.
Example: docker images --format "{{.ID}}\t{{.Repository}}\t{{.Tag}}\t{{.Size}}"
This command would output the image ID, repository, tag, and size, separated by tabs.

REPOSITORY AND TAG FILTERING

You can append a REPOSITORY[:TAG] argument to the command to narrow down the displayed images.
Example: docker images ubuntu (lists all ubuntu images)
Example: docker images nginx:latest (lists the specific nginx:latest image)

HISTORY

The docker images command has been a core part of the Docker CLI since its early days, providing a straightforward way to inspect local images. While docker image ls was introduced as part of the more structured docker <object> <command> syntax (e.g., docker container ls, docker volume ls), docker images remains fully functional and widely used for its familiarity and brevity.

SEE ALSO

docker(1), docker-build(1), docker-pull(1), docker-rmi(1), docker-run(1), docker-prune(1)

Copied to clipboard