- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to list images in Docker?
Docker provides a plethora of useful Docker commands that will help you to create, manipulate, and manage Docker objects such as volumes, images, containers, networks, etc. If you have been working with Docker for a long time now, you might have several Docker images already in your machine. Keeping track of all these images becomes quite difficult especially through a single command line.
However, you can list all Docker images along with filtered outputs to get your desired results. In this article, we will discuss how to use different commands along with multiple options to list all Docker images in our host machine.
Listing Docker Images
There are two major commands that can be used interchangeably to list Docker images and both of them provide the same results. The syntaxes of both these commands are mentioned below.
$ docker image ls [OPTIONS] [REPOSITORY[:TAG]]
You can use multiple options along with this command. These are -
- --digests - It is used to print the digests of the images.
- --filter - You can use this option to filter your output.
- --format - You can pretty-print output using a Go template.
- --no-trunc - You can use this to avoid output truncate.
- --quiet - Display only IDs of images.
- --all - You can list intermediate images using this option.
Another command to achieve the same result is -
$ docker images
Let’s discuss a few examples to modify your result output.
If you want to list only those images that belong to a particular repository, you can use the following command.
$ docker images <repository-name>:<tag-name>
For example, if you want to list all the nginx images, you can use the following command.
$ docker images nginx
You can also provide the tag name along with the name of the image repository.
$ docker images nginx:latest
If you see the results carefully, you will find that the Docker images list command displays the image list by truncating the IDs of the images. If you want to override this default behaviour, you can use the --no-trunc option. Let’s see how to do so.
$ docker images --no-trunc
If you want to list the digests of the images as well, you can simply use the --digests option along with the Docker images command. Image digests are unique IDs given to each tagged image that is often used to check for similar images.
$ docker images --digests
If you want to list all the dangling or untagged images, you can use the --filter option to do so. You need to provide appropriate key-value pairs. Some examples of filters that you can provide are - label, dangling, before, since, and reference. Let’s see how to list all the dangling images.
$ docker images --filter "dangling=true"
If you want to filter all those images that were created before a particular image, you can use the before filter.
$ docker images --filter "before=fedora"
The above command will display a list of all images that were created before the fedora image in your host machine. To list images that were created after a particular image, you can use the since filter.
$ docker images --filter "since=fedora"
You can also use the reference option to list images matching a particular pattern. For example, if you want to list all images starting with the letter m, you can use the following command.
$ docker images --filter=reference='m*'
To list all the images including intermediate and dangling ones, you can use the --all option.
$ docker images --all
If you want to print only the IDs of the images, you can use the --quiet option.
$ docker images --quiet
You can also use the --format option to pretty-print the output using a Go template. Let’s see how to do so.
$ docker images --format "The Image ID for the image is {{.ID}} belonging to {{.Repository}}"
Other placeholders that you can use are tag, ID, digest, size, createdat, createdsince, etc.
Final Thoughts!
To sum up, in this article we discussed how to use two different commands to list all the Docker images in your host machine. We saw how to use several different options to format the output according to our requirements. We looked at multiple options such as quiet, all, digest, format, filter, etc. We certainly hope that you will now be able to use the Docker image list command in the most precise manner to get accurate results.
- Related Articles
- How to list containers in Docker?
- How to save all Docker images and copy to another machine?
- How to run amd64 Docker images on the arm64 host platform?
- Searching and pulling Docker Images from Dockerhub
- How to add images in select list in HTML?
- How to copy Docker images from one host to another without using a repository?
- Using Images as List Markers in CSS
- In CSS using Images as List Markers
- How to display a list of images and text in a ListView in Android?
- How to ignore files in Docker?
- How to Hot-Reload in ReactJS Docker?
- How to remove old Docker containers?
- How to find Docker container processes?
- How to run Gunicorn on Docker?
- How to flatten a Docker image?
