【Self-study Docker】Docker inspect command

Docker inspect instruction

outline

insert image description here

docker inspect tutorial

Using the docker inspect command can be used to obtain the metadata of a Docker container or a Docker image . The CONTAINER after this command can be the container ID or the container name.

docker inspect syntax

haicoder(www.haicoder.net)# docker inspect [OPTIONS] NAME|ID [NAME|ID...]

docker inspect parameter

options illustrate
-f Specifies the template file for the return value.
-s Displays the total file size.
–type Return JSON for the specified type.

the case

Get image information

Use the docker inspect image command to obtain information about images.

haicoder(www.haicoder.net)# docker inspect ubuntu

After running, the terminal displays information as shown in the figure below:

Please add a picture description

Get container information

Use the docker run -it -d command to start a dokcer container.

haicoder(www.haicoder.net)# docker run -it --name haicoder -d ubuntu
dad9957dd11ae68a696a0eb547fc91d62bf2b0bb4198e37cd8a3c95f22f57cba

Use the docker inspect container command to obtain information about containers.

haicoder(www.haicoder.net)# docker inspect haicoder

After running, the terminal displays information as shown in the figure below:

Please add a picture description

Use **docker kill** and docker rm commands to remove all containers.

haicoder(www.haicoder.net)# docker kill `docker ps -qa` ; docker rm `docker ps -aq`

Get container name

Use the docker run -it -d command to start a dokcer container.

haicoder(www.haicoder.net)# docker run -it --name haicoder -d ubuntu 
#输出
75c1a52ce15c901e05b3a0803e25734b7c21fbf1ba8535bdb021b3eacd7609d8

Use the docker inspect container -f { {.Name}} command to get the container name.

haicoder(www.haicoder.net)# docker inspect haicoder -f {
    
    {.Name}}  
#输出
/haicoder

After running, the terminal outputs the container name information. Finally, we use the docker kill and docker rm commands to remove all containers.

haicoder(www.haicoder.net)# docker kill `docker ps -qa` ; docker rm `docker ps -aq`

Get container network settings information

Use the docker run -it -d command to start a dokcer container.

haicoder(www.haicoder.net)# docker run -it --name haicoder -d ubuntu               
0fc89059202e6c6c517b8849461238bccf045eaa6927e8d85fbf1f831de61a1a

Use the docker inspect CONTAINER -f { {.NetworkSettings}} command to get information about container network settings.

haicoder(www.haicoder.net)# docker inspect -f {
    
    {.NetworkSettings}} haicoder
#输出
{
    
    {
    
    61bdad2e0543a357670efc9cbffda77e04279ddb01f6bd54b8117fbf190617e5 false  0 map[] /var/run/docker/netns/61bdad2e0543 [] []} {
    
    b58143d00df2e21884bfa94660bc46bc776028d41dda47b25d7090912703f5fd 172.17.0.1  0 172.17.0.2 16  02:42:ac:11:00:02} map[bridge:0xc000598000]}

After running, the terminal outputs information about the network settings of the container. Finally, we use the docker kill and docker rm commands to remove all containers.

haicoder(www.haicoder.net)# docker kill `docker ps -qa` ; docker rm `docker ps -aq`

Get container IP information

Use the docker run -it -d command to start a dokcer container.

haicoder(www.haicoder.net)# docker run -it --name haicoder -d ubuntu 
ec342264b9debef5ac8a885f1479e8f3b9ef1c60bc70231063c849bcc930deac

Use the docker inspect container -f { {.NetworkSettings.IPAddress}} command to obtain information about the IP address of the container.

haicoder(www.haicoder.net)# docker inspect -f {
    
    {.NetworkSettings.IPAddress}} haicoder
#输出
172.17.0.2

After running, the terminal outputs the IP information of the container. Finally, we use the docker kill and docker rm commands to remove all containers.

haicoder(www.haicoder.net)# docker kill `docker ps -qa` ; docker rm `docker ps -aq`

docker inspect command summary

Use the docker inspect image command to obtain information about the Docker image, and use the docker inspect CONTAINER command to obtain information about the Docker container.

Use the docker inspect CONTAINER -f { {.Name}} command to get the container name.

Use the docker inspect CONTAINER -f { {.NetworkSettings}} command to get information about container network settings.

Use the docker inspect CONTAINER -f { {.NetworkSettings.IPAddress}} command to obtain information about the IP address of the container.

Guess you like

Origin blog.csdn.net/weixin_41384860/article/details/128714568