Docker Tutorial
Docker Installation
How to use Docker
Docker Instance
Docker Container Lifecycle Command
Docker Container Operation Command
Docker Container rootfs Command
Docker Mirror Repository Command
Docker Local Image Management Command
Docker info|version Command
The docker images
command allows you to list and manage the Docker images on your local system. This tutorial will guide you through the basics of using the docker images
command.
Prerequisites:
docker pull ubuntu:20.04
This command will download the ubuntu:20.04
image from Docker Hub.
List Docker images:
To display a list of Docker images on your system, run:
docker images
This will display a table with the following columns:
REPOSITORY
: The name of the image repository.TAG
: The image tag.IMAGE ID
: The unique identifier of the image.CREATED
: The time the image was created.SIZE
: The size of the image.Filter Docker images:
You can use filters to narrow down the list of images being displayed. To do this, use the --filter
or -f
flag followed by the filter you want to apply.
For example, to display only images from the "ubuntu" repository, use:
docker images --filter 'reference=ubuntu:*'
This command will list all images whose repository name starts with "ubuntu".
Display images with a specific tag:
To display only images with a specific tag, you can use the REPOSITORY:TAG
format.
For example, to display only images with the "20.04" tag, use:
docker images ubuntu:20.04
Format the output:
By default, the docker images
command displays images in a table format. If you want to change the output format, you can use the --format
or -f
flag followed by a Go template string.
For example, to display images with a custom format, use:
docker images --format '{{.Repository}}:{{.Tag}}\t{{.Size}}'
This command will display images with the repository name, tag, and size, separated by tabs.
Display image digests:
To display the image digests along with the other details, use the --digests
or -D
flag:
docker images --digests
This will add a DIGEST
column to the table, which displays the image digests.
Display all images:
By default, the docker images
command only displays the top-level images. To display all images, including intermediate images, use the -a
or --all
flag:
docker images -a
In this tutorial, we covered the basics of using the docker images
command to list and manage Docker images on your local system. By using filters, specific tags, custom output formatting, and additional options, you can tailor the output to your specific needs and gain valuable insights into your Docker images.
How to Use Docker Images Command:
docker images
command provides a list of Docker images on your local system.docker images
Listing Docker Images with Images Command:
docker images
Docker Images Command Options:
docker images
command supports various options for customizing the output, including formatting, filtering, and more.docker images --format "table {{.Repository}}\t{{.Tag}}\t{{.Size}}"
Filtering Docker Images Output:
docker images --filter "reference=myimage:*"
Sorting Docker Images with Images Command:
docker images --format "table {{.Repository}}\t{{.Tag}}\t{{.Size}}" | sort -k3 -h
Viewing Image Sizes with Docker Images:
docker images
command displays the size of each image, helping you understand the storage impact of different images.docker images --format "table {{.Repository}}\t{{.Tag}}\t{{.Size}}"
Docker Images and Image IDs:
docker images --format "table {{.Repository}}\t{{.Tag}}\t{{.ID}}"
Inspecting Docker Images Details with Images Command:
docker images
command provides a summary, but you can use docker inspect
for more detailed information about a specific image.docker inspect <image_id>
Removing Docker Images with Images Command:
docker rmi
command to remove one or more images from the local system.docker rmi <image_id>
Docker Images vs Docker ps:
docker images
lists available images, docker ps
shows running containers. They serve different purposes in managing Docker resources.docker ps