Docker Config Reference (docker images)
We go over many examples of using the docker images command!
The docker image command serves as a parent or management command within the Docker CLI, providing a suite of subcommands for handling Docker images. It encompasses operations such as listing (docker image ls), removing (docker image rm), pruning unused images (docker image prune), inspecting details (docker image inspect), and more. This structure allows for comprehensive image management, enabling users to perform targeted actions on images stored locally or interact with registries. In essence, docker image acts as a gateway to a broader set of image-related functionalities, promoting organized and extensible workflows in containerized environments.
In contrast, the docker images command is a legacy alias or shortcut specifically for docker image ls, which lists locally available Docker images. It does not support subcommands and is limited to enumeration tasks, displaying attributes like repository, tag, image ID, creation time, and size. While functionally equivalent to docker image ls in output, docker images is retained for backward compatibility but is less versatile, as it cannot access the full range of image management capabilities offered by the parent docker image command. Users are encouraged to adopt docker image ls for consistency in modern Docker practices.
Example 1
docker images
This command lists all top-level locally stored Docker images, displaying repository, tag, image ID, creation time, and size, which is the default behavior for basic inventory checks in a standard development setup.
Example 2
docker images --all
This command lists all images, including intermediate layers from builds, providing a complete view for identifying unused or dangling layers in a cluttered local registry.
Example 3
docker images --filter "dangling=true"
This command filters and lists only dangling (untagged) images, aiding in cleanup operations to free disk space on resource-limited hosts.
Example 4
docker images --format "{{.Repository}}:{{.Tag}}"
This command formats the output to show only repository and tag, which is useful for generating a simple list in scripting or automation tasks.
Example 5
docker images --quiet
This command lists only the image IDs in quiet mode, suitable for piping into other commands like removal scripts for batch processing.
Example 6
docker images nginx
This command lists all images with the repository name "nginx", regardless of tag, helping to identify multiple versions of a web server image.
Example 7
docker images --filter "reference=alpine:*"
This command filters images matching the reference pattern "alpine:*", displaying all tagged variants of the Alpine base image for version management.
Example 8
docker images --filter "before=ubuntu:22.04"
This command lists images created before the "ubuntu:22.04" image, assisting in chronological cleanup of outdated base images.
Example 9
docker images --filter "since=mysql:8.0"
This command lists images created since the "mysql:8.0" image, which is valuable for reviewing recent additions in a database-focused workflow.
Example 10
docker images --format "table {{.ID}}\t{{.Size}}"
This command tabulates image IDs and sizes, enabling quick assessment of storage usage in capacity planning scenarios.
Example 11
docker images --filter "label=com.example.env=prod"
This command filters images with the label "com.example.env=prod", supporting organized retrieval in labeled production environments.
Example 12
docker images --no-trunc
This command lists images with full, untruncated IDs and digests, ensuring precision in security audits or when dealing with long hashes.
Example 13
docker images --digests
This command includes image digests in the output, which is critical for verifying image integrity in secure supply chain practices.
Example 14
docker images redis --format "{{.CreatedAt}}"
This command formats output to show only creation times for "redis" images, aiding in identifying the most recent versions.
Example 15
docker images --filter "is-automated=true"
This command lists automated build images from Docker Hub, helping to discover officially maintained repositories for automated workflows.
Example 16
docker images --filter "is-official=true"
This command filters official images, ensuring selection of trusted, vendor-maintained images for compliance-sensitive applications.
Example 17
docker images --quiet --all
This command quietly lists IDs of all images, including intermediates, for comprehensive scripting in cleanup routines.
Example 18
docker images --format "{{json .}}"
This command outputs each image's details in JSON format, enabling easy integration with JSON-processing tools for custom reporting.
Example 19
docker images busybox --no-trunc --digests
This command lists "busybox" images with full details and digests, supporting detailed inspections of utility images.
Example 20
docker images --filter "label=org.opencontainers.image.version=1.0"
This command filters images by a specific version label, facilitating version-specific management in CI/CD pipelines.
Example 21
docker images --filter "dangling=false"
This command lists non-dangling (tagged) images, excluding untagged ones for focused active image reviews.
Example 22
docker images --format "table {{.Repository}}\t{{.CreatedSince}}"
This command tabulates repositories and relative creation times, helping track image age in maintenance tasks.
Example 23
docker images golang --quiet
This command quietly lists IDs of "golang" images, for quick extraction in build automation scripts.
Example 24
docker images --filter "reference=*:latest"
This command lists all images tagged "latest", identifying default versions across repositories.
Example 25
docker images --all --format "{{.ID}} {{.ParentID}}"
This command includes intermediates and formats to show IDs and parent IDs, revealing layer dependencies.
Example 26
docker images --digests --no-trunc postgres
This command lists "postgres" images with full digests and details, for cryptographic verification in secure databases.
Example 27
docker images --filter "before=2023-01-01"
This command lists images created before January 1, 2023, supporting archival or deletion of legacy images.
Example 28
docker images --format "{{.Labels}}"
This command shows labels for all images, aiding in metadata-based organization or queries.
Example 29
docker images tensorflow --human=false
This command lists "tensorflow" images with raw sizes, for exact storage metrics in ML workflows.
Example 30
docker images --filter "label=com.docker.compose.project=myproject"
This command filters images by a Compose project label, isolating project-specific images in multi-project setups.