December 08, 2017

Docker Commands: docker inspect

Docker Commands: docker inspect


docker inspect

Return low-level information on Docker objects

The target of this command is an object that can be identified via a Name or an ID, e.g. image, container, network, service, etc.

The output of the command is information about the object displayed as a JSON array.

@ubuntu:~$ docker inspect wizardly_jang
[
    {
        "Id": "c794e33bda6bfa60cdc039795ad7712c62df68ca5f8a6d14b906a6a06bc08e43",
        "Created": "2017-04-01T06:02:04.840341671Z",
        "Path": "nginx",
        "Args": [
            "-g",
            "daemon off;"
        ],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 4584,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2017-04-29T17:24:19.743601367Z",
            "FinishedAt": "2017-04-29T17:23:24.201882506Z"
        },
        "Image": "sha256:6b914bbcb59e49851990e064568dceee4d53a462f316ec36207599c12ae9ba65",
        "ResolvConfPath": "/var/lib/docker/containers/c794e33bda6bfa60cdc039795ad7712c62df68ca5f8a6d14b906a6a06bc08e43/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/c794e33bda6bfa60cdc039795ad7712c62df68ca5f8a6d14b906a6a06bc08e43/hostname",
        "HostsPath": "/var/lib/docker/containers/c794e33bda6bfa60cdc039795ad7712c62df68ca5f8a6d14b906a6a06bc08e43/hosts",
        "LogPath": "/var/lib/docker/containers/c794e33bda6bfa60cdc039795ad7712c62df68ca5f8a6d14b906a6a06bc06e43/c794e33bda6bfa60cdc039795ad7712c62df68ca5f8a6d14b906a6a06bc08e43-json.log",
        "Name": "/wizardly_jang",
        "RestartCount": 0,
        "Driver": "aufs",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "",
        "ExecIDs": null,
        "HostConfig": {
            "Binds": null,
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {}
            },
            "NetworkMode": "default",
            "PortBindings": {
                "80/tcp": [
                    {
                        "HostIp": "",
                        "HostPort": "8080"
                    }
                ]
            },
            "RestartPolicy": {
                "Name": "no",
                "MaximumRetryCount": 0
            },
            "AutoRemove": false,
            "VolumeDriver": "",
            "VolumesFrom": null,
            "CapAdd": null,
            "CapDrop": null,
            "Dns": [],
            "DnsOptions": [],
            "DnsSearch": [],
            "ExtraHosts": null,
            "GroupAdd": null,
            "IpcMode": "",
            "Cgroup": "",
            "Links": null,
            "OomScoreAdj": 0,
            "PidMode": "",
            "Privileged": false,
            "PublishAllPorts": false,
            "ReadonlyRootfs": false,
            "SecurityOpt": null,
            "UTSMode": "",
            "UsernsMode": "",
            "ShmSize": 67108864,
            "Runtime": "runc",
            "ConsoleSize": [
                0,
                0
            ],
            "Isolation": "",
            "CpuShares": 0,
            "Memory": 0,
            "NanoCpus": 0,
            "CgroupParent": "",
            "BlkioWeight": 0,
            "BlkioWeightDevice": null,
            "BlkioDeviceReadBps": null,
            "BlkioDeviceWriteBps": null,
            "BlkioDeviceReadIOps": null,
            "BlkioDeviceWriteIOps": null,
            "CpuPeriod": 0,
            "CpuQuota": 0,
            "CpuRealtimePeriod": 0,
            "CpuRealtimeRuntime": 0,
            "CpusetCpus": "",
            "CpusetMems": "",
            "Devices": [],
            "DiskQuota": 0,
            "KernelMemory": 0,
            "MemoryReservation": 0,
            "MemorySwap": 0,
            "MemorySwappiness": -1,
            "OomKillDisable": false,
            "PidsLimit": 0,
            "Ulimits": null,
            "CpuCount": 0,
            "CpuPercent": 0,
            "IOMaximumIOps": 0,
            "IOMaximumBandwidth": 0
        },
        "GraphDriver": {
            "Name": "aufs",
            "Data": null
        },
        "Mounts": [],
        "Config": {
            "Hostname": "c794e33bda6b",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "443/tcp": {},
                "80/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "NGINX_VERSION=1.11.10-1~jessie"
            ],
            "Cmd": [
                "nginx",
                "-g",
                "daemon off;"
            ],
            "ArgsEscaped": true,
            "Image": "nginx",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": {}
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "a4e88604a69fad8bf3fc99c97444992c98e47dca983024edb2e55072db77560c",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {
                "443/tcp": null,
                "80/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "8080"
                    }
                ]
            },
            "SandboxKey": "/var/run/docker/netns/a4e88604a69f",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "a9a5fd1166429b6086accd128055e9992f772c929e8539225d2d57abb3741fa4",
            "Gateway": "172.17.0.1",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "172.17.0.2",
            "IPPrefixLen": 16,
            "IPv6Gateway": "",
            "MacAddress": "02:42:ac:11:00:02",
            "Networks": {
                "bridge": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": null,
                    "NetworkID": "0aeb282b8e82b97e693e77e5ae0237e9b32ebae09b6bf0510457ec6c516c2a0a",
                    "EndpointID": "a9a5fd1166429b6086accd128055e9992f772c929e8539225d2d57abb3741fa4",
                    "Gateway": "172.17.0.1",
                    "IPAddress": "172.17.0.2",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:ac:11:00:02"
                }
            }
        }
    }
]
@ubuntu:~$

To output a specific field, add the --format or -f option.

Use docker inspect --format "{{.NetworkSettings.IPAddress}}" <container ID> to view the IP Address section of the docker inspect output:


References:

Creative Commons License Licensed under a Creative Commons Attribution 4.0 International License.

No comments:

Post a Comment