使用 inspect 命令查看镜像详细信息,包括制作者、适应架构、各层的数字摘要等。
# docker inspect --help Usage: docker inspect [OPTIONS] NAME|ID [NAME|ID...] 返回Docker对象的底层信息 选项: -f, --format string 使用给定的Go模板格式化输出 -s, --size 如果类型是container,则显示总文件大小 --type string 返回指定类型的JSON
例如:创建ubuntu:18.04镜像,查询该镜像的信息
# docker pull ubuntu:18.04 //创建镜像 # docker images // 查询所有的镜像 REPOSITORY TAG IMAGE ID CREATED SIZE ubuntu 18.04 d131e0fa2585 13 days ago 102MB
# docker inspect ubuntu:18.04 // 查看镜像的详细信息 [ { "Id": "sha256:d131e0fa2585a7efbfb187f70d648aa50e251d9d3b7031edf4730ca6154e221e", "RepoTags": [ "ubuntu:18.04" ], "RepoDigests": [ "ubuntu@sha256:d26d529daa4d8567167181d9d569f2a85da3c5ecaf539cace2c6223355d69981" ], "Parent": "", "Comment": "", "Created": "2019-04-26T22:21:05.100534088Z", "Container": "8a681ed429a156522e3703d03bc9be8f543afca51f828e29e8bea369b2da5ac3", "ContainerConfig": { "Hostname": "8a681ed429a1", "Domainname": "", "User": "", "AttachStdin": false, "AttachStdout": false, "AttachStderr": false, "Tty": false, "OpenStdin": false, "StdinOnce": false, "Env": [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" ], "Cmd": [ "/bin/sh", "-c", "#(nop) ", "CMD [\"/bin/bash\"]" ], "ArgsEscaped": true, "Image": "sha256:84a91c92bc7d7ffc41fdc12d50d8c205330f2c2f5f6b6725def71a46782b0ab5", "Volumes": null, "WorkingDir": "", "Entrypoint": null, "OnBuild": null, "Labels": {} }, "DockerVersion": "18.06.1-ce", "Author": "", "Config": { "Hostname": "", "Domainname": "", "User": "", "AttachStdin": false, "AttachStdout": false, "AttachStderr": false, "Tty": false, "OpenStdin": false, "StdinOnce": false, "Env": [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" ], "Cmd": [ "/bin/bash" ], "ArgsEscaped": true, "Image": "sha256:84a91c92bc7d7ffc41fdc12d50d8c205330f2c2f5f6b6725def71a46782b0ab5", "Volumes": null, "WorkingDir": "", "Entrypoint": null, "OnBuild": null, "Labels": null }, "Architecture": "amd64", "Os": "linux", "Size": 101749224, "VirtualSize": 101749224, "GraphDriver": { "Data": { "LowerDir": "/var/lib/docker/overlay2/14c1542a6a61092a163802f3203e0512cb1fa153eca5cda828924c46822e0eaf/diff:/var/lib/docker/overlay2/3d8d8a83488a0033eeed1959ac5507e28726de2d83ba532f8f732a7281289b98/diff:/var/lib/docker/overlay2/71a99fbfabcd98c9c6f3d5aa99ccf2e837e37c293a22d01f9cf94c2e188dbadc/diff", "MergedDir": "/var/lib/docker/overlay2/50abaded2d1867213face044a814770c0d74fefc8b78b5776aa2c05c148147e3/merged", "UpperDir": "/var/lib/docker/overlay2/50abaded2d1867213face044a814770c0d74fefc8b78b5776aa2c05c148147e3/diff", "WorkDir": "/var/lib/docker/overlay2/50abaded2d1867213face044a814770c0d74fefc8b78b5776aa2c05c148147e3/work" }, "Name": "overlay2" }, "RootFS": { "Type": "layers", "Layers": [ "sha256:604cbde1a4c8fee1b102f8b64d4f41e62d770b5f8a6b06fb809cfd873a2643c3", "sha256:5d74a98c48bcfc2d04e9d679ea095d360ac0b2f2a27312c8e95a7f5ba5341d9c", "sha256:94e5c4ea5da6d2a5e0232458e8f14a2cdba0d0f0ce1bdd8098789477c89a7f45", "sha256:7660ded5319c352f98b8b305b6bd11a501b9704f5e31d1e3b1d3da644f1c3fb8" ] }, "Metadata": { "LastTagTime": "0001-01-01T00:00:00Z" } } ]
查看镜像的某一项信息:-f
查看镜像的Os信息:
# docker inspect -f {{".Os"}} ubuntu:18.04 linux
查看镜像的Config信息
# docker inspect -f {{".Config"}} ubuntu:18.04 { false false false map[] false false false [PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin] [/bin/bash] <nil> true sha256:84a91c92bc7d7ffc41fdc12d50d8c205330f2c2f5f6b6725def71a46782b0ab5 map[] [] false [] map[] <nil> []}
努力成为一名优秀的工程师