How to view image information in Docker

How to view image information in Docker

In this article, we will need to learn how to view image information in Docker

1. The images command lists images

Use the following two commands to list the existing images on the local machine:

docker images

or:

docker image ls

As shown in the following figure:

Docker View Image Information

Explain the fields marked in red above:

  • REPOSITORY : From which repository;
  • TAG : The tag information of the image, such as 5.7 and latest, which represent different version information;
  • IMAGE ID : The ID of the image. If you see two IDs that are exactly the same, they actually point to the same image, but with different tag names.
  • CREATED : The last update time of the image;
  • SIZE : The size of the image. Excellent images are generally small in size, which is why I prefer to use the lightweight alpine version;

Note: The image size information in the figure is only logical size information, because an image is composed of multiple image layer , and the same image layer is only stored locally. Therefore, in reality, the physical storage space occupied may be smaller than the logical size.

2. Use the tag command to add tags to the image

Usually, in order to quickly find a certain image in subsequent work, we can use the docker tag command to add a new tag to the local image. As shown in the following figure:

Docker tag

For the docker.io/mysql image, add a new image tag allen_mysql:5.7 . Then use the docker images command to view the local image:

Docker tag

As you can see, there is an additional allen_mysql:5.7 mirror locally. If you are careful, you will definitely find that the image IDs of allen_mysql:5.7 and docker.io/mysql:5.7 are exactly the same, which means they are the same image, but with different aliases.

The docker tag command is more like adding a shortcut to a specified image.

3. Use the inspect command to view image details

Through the docker inspect command, we can get detailed information about the image, including the creator, numerical summaries of each layer, etc.

docker inspect docker.io/mysql:5.7 

Docker inspect to view image details

docker inspect returns information in JSON format. If you want to obtain a specific content, you can specify it through -f , such as obtaining the image size:

docker inspect -f {{".Size"}} docker.io/mysql:5.7 

Docker inspect to view image details

4. Use the history command to view the image history

In the previous section, we know that an image is composed of multiple layers. So, how do we know the specific content of each layer?

The docker history command can be used to list the creation information of each layer. For example, we can view the information of each layer of docker.io/mysql:5.7 :

docker history docker.io/mysql:5.7 

Docker history layer information

As you can see, the above information is too long. For the convenience of display, it is omitted later. If you want to see the specific information, you can add the --no-trunc option, as shown in the following command:

docker history --no-trunc docker.io/mysql:5.7

V. Conclusion

In this article, we focused on how to view image information in Docker, as well as the functions of the tag command, inspect command, and history command.

This is the end of this article about how to view image information on Docker. For more information about how to view image information on Docker, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Docker Modify Docker storage location Modify container image size limit operation
  • How to modify the storage location of Docker default images and containers
  • How to modify the default storage location of Docker images (solution)

<<:  Detailed explanation of the process of creating floor navigation effects with JavaScript

>>:  What are the benefits of using B+ tree as index structure in MySQL?

Recommend

HTML tutorial, understanding the optgroup element

Select the category selection. After testing, IE ...

Mariadb remote login configuration and problem solving

Preface: The installation process will not be des...

Detailed process of building mysql5.7.29 on centos7 of linux

1. Download MySQL 1.1 Download address https://do...

Solution to Linux server graphics card crash

When the resolution of the login interface is par...

Nginx signal control

Introduction to Nginx Nginx is a high-performance...

Tutorial on installing MYSQL8.0 on Alibaba Cloud ESC

Open the connection tool. I use MobaXterm_Persona...

Solution to the error problem of Vscode remotely connecting to Ubuntu

1. Background of the incident: Because of work ne...

MySQL trigger definition and usage simple example

This article describes the definition and usage o...

Shell script to monitor MySQL master-slave status

Share a Shell script under Linux to monitor the m...

mysql 8.0.19 win10 quick installation tutorial

This tutorial shares the installation tutorial of...

Analyzing the four transaction isolation levels in MySQL through examples

Preface In database operations, in order to effec...

Detailed explanation of how to use Node.js to implement hot reload page

Preface Not long ago, I combined browser-sync+gul...

Detailed explanation of MySQL execution plan

The EXPLAIN statement provides information about ...