Docker Images
Intermediate Images & Dangling Images
As seen earlier in this guide, containerd pulls images and stores their raw data as content blobs under /var/lib/containerd/io.containerd.content.v1.content/. Each blob is addressed by a digest and may represent a layer, a manifest, or a configuration file. Images are reconstructed from metadata that references these blobs.
docker image ls (same as docker images) shows the list of top-level, tagged images that Docker considers directly usable. By default, it doesn't show every image object that exists on disk. Some image data can still be present locally but hidden from the default output:
Intermediate images: These are images created during docker build as part of a multi-step build (a process where the final image is built in several stages). They usually have no repository name or tag. Docker keeps them to speed up future builds by reusing cached layers. Intermediate images are not shown by default, but they do appear when you use:
docker image ls -a
Dangling images: These are images that have no tag and are not referenced by any named image. They often appear after rebuilding an image with the same tag, when the old image becomes untagged. Dangling images are also hidden by default, but they can be listed with:
docker image ls -f dangling=true
or by using -a.
To remove these unused images (both intermediate and dangling), you can use:
docker image prune
Note that docker image prune only removes dangling images by default, but docker image prune -a removes images without at least one container associated with them and dangling images.
Searching for Images
Docker Hub - the default public repository of Docker images - offers a user-friendly web interface to search for images. However, you can also search for images directly from the command line using the docker search command followed by the name of the image you are looking for.
For example, to search using the keywords busybox, you would run:
docker search busybox
Painless Docker - 2nd Edition
A Comprehensive Guide to Mastering Docker and its EcosystemEnroll now to unlock all content and receive all future updates for free.
Hurry! This limited time offer ends in:
To redeem this offer, copy the coupon code below and apply it at checkout:
