OngaLog

最近GOが楽しくて、

Dockerのコンテナに割り振られているIP情報を確認する

Dockerに割り振られている、IP情報を確認したいときのコマンド。

docker inspect <コンテナID>

IP意外にも設定情報が確認できる。

"IPAddress": "172.17.0.5",

IPはこの部分。

"Memory": 0,
"MemorySwap": 0,

みたいな情報もあって、この値をなにかに利用することもできそうだ。

"Args": [],

は何の値が入るのだろうか、?気になる。

[
{
    "Id": "cf067df275fb76b595d8b5fa700d4f672c5d7e6d3bf6a7ea2ace940a247aade3",
    "Created": "2016-11-09T06:21:13.362604567Z",
    "Path": "/bin/bash",
    "Args": [],
    "State": {
        "Running": true,
        "Paused": false,
        "Restarting": false,
        "OOMKilled": false,
        "Dead": false,
        "Pid": 19858,
        "ExitCode": 0,
        "Error": "",
        "StartedAt": "2016-11-09T06:21:18.454354979Z",
        "FinishedAt": "0001-01-01T00:00:00Z"
    },
    "Image": "77ef9a48cbcd426222db33780cde2594bd9a1f72a8c48baf737dfeaf531a90d7",
    "NetworkSettings": {
        "Bridge": "",
        "EndpointID": "fb5b7617aa6e12ddb0e93958a8d753a06e410d01a3ba896f507dc75f6e6a5a6c",
        "Gateway": "172.17.42.1",
        "GlobalIPv6Address": "",
        "GlobalIPv6PrefixLen": 0,
        "HairpinMode": false,
        "IPAddress": "172.17.0.5",
        "IPPrefixLen": 16,
        "IPv6Gateway": "",
        "LinkLocalIPv6Address": "",
        "LinkLocalIPv6PrefixLen": 0,
        "MacAddress": "02:42:ac:11:00:05",
        "NetworkID": "fce7ae5ca5414255cdde4c64956f841d82d8b3bcfd1328df209b1979741fe7d4",
        "PortMapping": null,
        "Ports": {
            "80/tcp": [
                {
                    "HostIp": "0.0.0.0",
                    "HostPort": "80"
                }
            ]
        },
        "SandboxKey": "/var/run/docker/netns/cf067df275fb",
        "SecondaryIPAddresses": null,
        "SecondaryIPv6Addresses": null
    },
    "ResolvConfPath": "/var/lib/docker/containers/cf067df275fb76b595d8b5fa700d4f672c5d7e6d3bf6a7ea2ace940a247aade3/resolv.conf",
    "HostnamePath": "/var/lib/docker/containers/cf067df275fb76b595d8b5fa700d4f672c5d7e6d3bf6a7ea2ace940a247aade3/hostname",
    "HostsPath": "/var/lib/docker/containers/cf067df275fb76b595d8b5fa700d4f672c5d7e6d3bf6a7ea2ace940a247aade3/hosts",
    "LogPath": "/var/lib/docker/containers/cf067df275fb76b595d8b5fa700d4f672c5d7e6d3bf6a7ea2ace940a247aade3/cf067df275fb76b595d8b5fa700d4f672c5d7e6d3bf6a7ea2ace940a247aade3-json.log",
    "Name": "/web",
    "RestartCount": 0,
    "Driver": "devicemapper",
    "ExecDriver": "native-0.2",
    "MountLabel": "",
    "ProcessLabel": "",
    "Volumes": {
        "/var/www/html": "/var/www/html"
    },
    "VolumesRW": {
        "/var/www/html": true
    },
    "AppArmorProfile": "",
    "ExecIDs": null,
    "HostConfig": {
        "Binds": [
            "/var/www/html:/var/www/html"
        ],
        "ContainerIDFile": "",
        "LxcConf": [],
        "Memory": 0,
        "MemorySwap": 0,
        "CpuShares": 0,
        "CpuPeriod": 0,
        "CpusetCpus": "",
        "CpusetMems": "",
        "CpuQuota": 0,
        "BlkioWeight": 0,
        "OomKillDisable": false,
        "Privileged": false,
        "PortBindings": {
            "80/tcp": [
                {
                    "HostIp": "",
                    "HostPort": "80"
                }
            ]
        },
        "Links": null,
        "PublishAllPorts": false,
        "Dns": null,
        "DnsSearch": null,
        "ExtraHosts": null,
        "VolumesFrom": null,
        "Devices": [],
        "NetworkMode": "bridge",
        "IpcMode": "",
        "PidMode": "",
        "UTSMode": "",
        "CapAdd": null,
        "CapDrop": null,
        "RestartPolicy": {
            "Name": "no",
            "MaximumRetryCount": 0
        },
        "SecurityOpt": null,
        "ReadonlyRootfs": false,
        "Ulimits": null,
        "LogConfig": {
            "Type": "json-file",
            "Config": {}
        },
        "CgroupParent": ""
    },
    "Config": {
        "Hostname": "cf067df275fb",
        "Domainname": "",
        "User": "",
        "AttachStdin": false,
        "AttachStdout": false,
        "AttachStderr": false,
        "PortSpecs": null,
        "ExposedPorts": {
            "80/tcp": {}
        },
        "Tty": true,
        "OpenStdin": true,
        "StdinOnce": false,
        "Env": [
            "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
        ],
        "Cmd": null,
        "Image": "tkcdocker/centos6-mt6-2016-11-08-update",
        "Volumes": null,
        "VolumeDriver": "",
        "WorkingDir": "",
        "Entrypoint": [
            "/bin/bash"
        ],
        "NetworkDisabled": false,
        "MacAddress": "",
        "OnBuild": null,
        "Labels": {}
    }
}
]