Docker inspect 命令

返回上一级

docker inspect 命令用于获取容器/镜像的元数据

docker inspect [OPTIONS] NAME|ID [NAME|ID...]
OPTIONS 说明
-f 指定返回值的模板文件
-s 显示总的文件大小
--type 为指定类型返回 JSON

范例 1

下面的命令用于获取正在运行的容器 d07b599f11e4 的 IP

[root@localhost ~]# docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' d07b599f11e4
172.17.0.2

范例 2

下面的命令用于获取镜像 python:3.6.5 的元信息

[root@localhost ~]# docker inspect python:3.6.5
[
    {
        "Id": "sha256:29d2f3226daf297b27f0240244f4e8d614fb63eeab8cd09d816e8b7b04d1c011",
        "RepoTags": [
            "python:3.6.5"
        ],
        "RepoDigests": [
            "python@sha256:b1d2ddc6ab464da30ef5b0ea415c716e3652bd9ebfdd70e7bb56925950a63e98"
        ],
        "Parent": "",
        "Comment": "",
        "Created": "2018-05-05T03:06:15.083137043Z",
        "Container": "a80fe91aa115a91f95f9da5199d4ed7957c391325d9aeb2db45bf629426a1012",
        "ContainerConfig": {
            "Hostname": "a80fe91aa115",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "LANG=C.UTF-8",
                "GPG_KEY=0D96DF4D4110E5C43FBFB17F2D347EA6AA65421D",
                "PYTHON_VERSION=3.6.5",
                "PYTHON_PIP_VERSION=10.0.1"
            ],
            "Cmd": [
                "/bin/sh",
                "-c",
                "#(nop) ",
                "CMD [\"python3\"]"
            ],
            "ArgsEscaped": true,
            "Image": "sha256:9e04e9501b0b415a6d89d4d5bdfeafc3438478abf3072a614687b9bf44da882e",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": null,
            "OnBuild": [],
            "Labels": {}
        },
        "DockerVersion": "17.06.2-ce",
        "Author": "",
        "Config": {
            "Hostname": "",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "LANG=C.UTF-8",
                "GPG_KEY=0D96DF4D4110E5C43FBFB17F2D347EA6AA65421D",
                "PYTHON_VERSION=3.6.5",
                "PYTHON_PIP_VERSION=10.0.1"
            ],
            "Cmd": [
                "python3"
            ],
            "ArgsEscaped": true,
            "Image": "sha256:9e04e9501b0b415a6d89d4d5bdfeafc3438478abf3072a614687b9bf44da882e",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": null,
            "OnBuild": [],
            "Labels": null
        },
        "Architecture": "amd64",
        "Os": "linux",
        "Size": 911631748,
        "VirtualSize": 911631748,
        "GraphDriver": {
            "Data": {
                "LowerDir": "/var/lib/docker/overlay2/bbe2bb725e52049d88783851ae23be15f976fe5139516303d4899cfdee22709e/diff:/var/lib/docker/overlay2/72d6008559c6aba886ac884f830433256051a12733766c1df2f92b83b67f05c9/diff:/var/lib/docker/overlay2/98aa3607b4690ae9d9a10c10aeb1c40efa66de7afa28f1fe0e4155f1ec078a89/diff:/var/lib/docker/overlay2/b3568bf61db10746ce6e43a9a37d3964edaadbaff1fd5ee653d8aa07a7d4f410/diff:/var/lib/docker/overlay2/0406d09287391bb0363decf29b37abb6f58480d3868a09bdf09ef1d2f98ad1e0/diff:/var/lib/docker/overlay2/b976d74397351f45c0d4efc97dc0d83f2a437841250862b5cd985f0a08604e6e/diff:/var/lib/docker/overlay2/68ec27af46ef6714c80e394801f6905776e815903d5df3fa8ab8c68b26b0a6d1/diff:/var/lib/docker/overlay2/171ef2419a8ff08cd332d44711bfb89bd460511bfeb49a6312aa1819fb5fe033/diff",
                "MergedDir": "/var/lib/docker/overlay2/841069c6ee986d2d8bc1e441708a6013ea5093b31ed6d0a392224ce29a14b3ec/merged",
                "UpperDir": "/var/lib/docker/overlay2/841069c6ee986d2d8bc1e441708a6013ea5093b31ed6d0a392224ce29a14b3ec/diff",
                "WorkDir": "/var/lib/docker/overlay2/841069c6ee986d2d8bc1e441708a6013ea5093b31ed6d0a392224ce29a14b3ec/work"
            },
            "Name": "overlay2"
        },
        "RootFS": {
            "Type": "layers",
            "Layers": [
                "sha256:0f3a12fef684003e8dc0dfdcea32789db2179c6f9ad1e1e89bc05754ac44c6c5",
                "sha256:76a66da94657e7ad051d747d65e73c4864d58a083766c1dec7af2b402ab8d674",
                "sha256:0f6f641d80caea49ffe2afe7947946c76453f4251fd9959d31bec9efb2378483",
                "sha256:fbbeadfbd3cad7b5ad7221cd5b3cdd8a912ea28e8c92666658108706611b8d7e",
                "sha256:90b8c3cde8759d3db35db532f0b10f31b94726a7deb47a5c4d86f0e3014e05e5",
                "sha256:f186354f2c39dd93295d7ad6d39c5a57fa4c57395963d39cec088c836019fd71",
                "sha256:f04225383530b57c2bd566afbcf1470b71e20e3959402bd0bd58b5f90b24db41",
                "sha256:9650e1239c3e982205811e182d1bf915850d18db3542e721d9a3a02928da8212",
                "sha256:31f8aa3851313b9adb7a0d581f20836e492684656189f0e27c5b1d2d656f70e4"
            ]
        },
        "Metadata": {
            "LastTagTime": "2018-05-31T10:04:52.6315341Z"
        }
    }
]

返回上一级

关于   |   FAQ   |   我们的愿景   |   广告投放   |  博客

  简单教程,简单编程 - IT 入门首选站

Copyright © 2013-2022 简单教程 twle.cn All Rights Reserved.