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

Execute initialization sql when docker mysql starts

1. Pull the Mysql image docker pull mysql:5.7 2. ...

Master-slave synchronous replication configuration of MySQL database under Linux

The advantage of the master-slave synchronization...

Vue3.0 handwriting magnifying glass effect

The effect to be achieved is: fixed zoom in twice...

What are HTML inline elements and block-level elements and their differences

I remember a question the interviewer asked durin...

React configuration px conversion rem method

Install related dependencies npm i lib-flexible -...

Several common ways to deploy Tomcat projects [tested]

1 / Copy the web project files directly to the we...

Summary of basic knowledge points of Linux group

1. Basic Introduction of Linux Group In Linux, ev...

Summary of 4 ways to add users to groups in Linux

Preface Linux groups are organizational units use...

Vue implements custom "modal pop-up window" component example code

Table of contents Preface Rendering Example Code ...

Detailed installation process of MySQL5.6.40 under CentOS7 64

MySQL5.6.40 installation process under CentOS7 64...

Nest.js hashing and encryption example detailed explanation

0x0 Introduction First of all, what is a hash alg...

Notes on the MySQL database backup process

Today I looked at some things related to data bac...

Example code for implementing fullpage.js full-screen scrolling effect with CSS

When I was studying CSS recently, I found that I ...

Idea deploys remote Docker and configures the file

1. Modify the Linux server docker configuration f...

MySQL prepare principle detailed explanation

Benefits of Prepare The reason why Prepare SQL is...