Listing Local Images and Reading Image Metadata
How to list, filter, sort, and inspect local Docker images using docker image ls, docker inspect, and Go template formatting strings.
Published on • November 18, 2026
AI Assistant

As your containerized development environment grows, your local Docker storage accumulates base images, application builds, dangling intermediate layers, and multi-stage test targets. Managing local image inventory efficiently requires mastering docker image ls and deep metadata inspection tools like docker inspect.
In this tutorial, we will learn how to list local images, filter by metadata properties, extract specific JSON fields using Go templates, and measure real disk footprint.
Listing Local Docker Images
The modern command for listing stored images is:
docker image ls
(Note: docker images is an alias maintained for backward compatibility).
The command produces an overview of locally stored images:
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx 1.25 92b11f4d1571 2 days ago 187MB
node 20-slim a747a829e211 1 week ago 210MB
<none> <none> f3b7d19c0042 3 weeks ago 85MB
Viewing Content-Addressable Digests
By default, docker image ls shows human-friendly tags. To inspect the exact SHA-256 repo digests (essential for verifying immutability):
docker image ls --digests
Output:
REPOSITORY TAG DIGEST IMAGE ID SIZE
nginx 1.25 sha256:4c0f3f20865ebd3757f40660bc9b7b038b69da3851ab424a2ae7f29feabcb285 92b11f4d1571 187MB
Advanced Filtering with --filter
You can pass --filter (or -f) key-value pairs to isolate specific subsets of images.
1. Finding Dangling Images
Dangling images are untagged layers (<none>:<none>) created when building new versions of an existing tag or replacing image layers:
docker image ls --filter "dangling=true"
2. Filtering by Creation Date or Reference
# Images created before a specific reference image
docker image ls --filter "before=nginx:1.25"
# Images created after a reference image
docker image ls --filter "since=ubuntu:22.04"
# Filter by repository name pattern
docker image ls --filter "reference=node:*"
3. Filtering by OCI Labels
If your Dockerfiles include LABEL instructions (such as maintainer, environment, or component):
docker image ls --filter "label=environment=production"
Reading Detailed Metadata with docker inspect
To inspect full image configuration—including environment variables, default command, architecture, entrypoint, exposed ports, and layer digests:
docker inspect nginx:1.25
This returns a detailed JSON payload. You can extract specific metadata using the --format flag with Go template syntax.
Practical docker inspect Formatting Examples
# 1. Get the Architecture and OS
docker inspect --format='{{.Os}}/{{.Architecture}}' nginx:1.25
# Output: linux/amd64
# 2. Extract Default Environment Variables
docker inspect --format='{{json .Config.Env}}' node:20-slim | jq .
# 3. View the Entrypoint and Default Command
docker inspect --format='Entrypoint: {{.Config.Entrypoint}} | CMD: {{.Config.Cmd}}' python:3.11-alpine
# 4. List Layer Diff IDs (Filesystem Layers)
docker inspect --format='{{range .RootFS.Layers}}{{println .}}{{end}}' redis:alpine
Formatting docker image ls Output
The --format flag can also be used on docker image ls to build clean tabular views for scripts:
# Display Repository, Tag, ID, and Size in aligned columns
docker image ls --format "table {{.Repository}}\t{{.Tag}}\t{{.ID}}\t{{.Size}}"
# Output a JSON array of all local images
docker image ls --format '{"repository":"{{.Repository}}","tag":"{{.Tag}}","size":"{{.Size}}"}'
Summary & Useful Commands
| Action | Command |
|---|---|
| List all images | docker image ls |
| Show digests | docker image ls --digests |
| Show dangling images | docker image ls -f "dangling=true" |
| Inspect raw JSON metadata | docker inspect <image_id> |
| Extract OS/Arch metadata | docker inspect --format='{{.Os}}/{{.Architecture}}' <image_name> |
Mastering image metadata inspection allows developers and platform engineers to verify build integrity, validate OCI labels, and audit base configurations efficiently.