Docker Images

Table of contents
  1. Docker Image / Images
    1. Image
    2. Images
  2. Dangling images
    1. Remove dangling images

Docker Image / Images

You may have noticed that there are two Docker CLI commands that seem similar

  • docker image
  • docker images

There is a bit of a difference between the two.

Image

Actually builds, pulls, and removes images. This command is used to physically manage the images.

You can of course list images as well.

docker image ls

Images

This has to do with displaying in a high-level fashion what kind of images exist.

Primary purpose is to display image metadata.

docker images

Dangling images

When you do

docker images -a | grep '<none>'
# OR
docker image ls -a | grep '<none>'

Or check the Images tab in Docker Desktop, you may see a bunch of images with the name and tag of <none>.

This is a residue / intermediate image created from previous image builds.

It seems they exist as a cached layer for subsequent builds. But it is safe to delete them.

Remove dangling images

You can remove these dangling images by

docker image prune

docker image prune -a not only removes dangling images but also any unused images. This can come in handy, but if you’re keeping any pulled Docker registry images (unused in containers at the moment) in your local storage for some reason, this is not what you want.