mirror of https://github.com/docker/cli.git
docker-inspect: Extend docker inspect to export image/container metadata related to graph driver
Export image/container metadata stored in graph driver. Right now 3 fields DeviceId, DeviceSize and DeviceName are being exported from devicemapper. Other graph drivers can export fields as they see fit. This data can be used to mount the thin device outside of docker and tools can look into image/container and do some kind of inspection. Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
This commit is contained in:
parent
7507a5b7ab
commit
147a754d4a
|
@ -30,143 +30,144 @@ each result.
|
||||||
|
|
||||||
To get information on a container use its ID or instance name:
|
To get information on a container use its ID or instance name:
|
||||||
|
|
||||||
$ docker inspect 1eb5fabf5a03
|
$ docker inspect d2cc496561d6
|
||||||
[{
|
[{
|
||||||
"AppArmorProfile": "",
|
"Id": "d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47",
|
||||||
"Args": [],
|
"Created": "2015-06-08T16:18:02.505155285Z",
|
||||||
"Config": {
|
"Path": "bash",
|
||||||
"AttachStderr": false,
|
"Args": [],
|
||||||
"AttachStdin": false,
|
"State": {
|
||||||
"AttachStdout": false,
|
"Running": false,
|
||||||
"Cmd": [
|
"Paused": false,
|
||||||
"/usr/sbin/nginx"
|
"Restarting": false,
|
||||||
],
|
"OOMKilled": false,
|
||||||
"Domainname": "",
|
"Dead": false,
|
||||||
"Entrypoint": null,
|
"Pid": 0,
|
||||||
"Env": [
|
"ExitCode": 0,
|
||||||
"HOME=/",
|
"Error": "",
|
||||||
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
"StartedAt": "2015-06-08T16:18:03.643865954Z",
|
||||||
],
|
"FinishedAt": "2015-06-08T16:57:06.448552862Z"
|
||||||
"ExposedPorts": {
|
},
|
||||||
"80/tcp": {}
|
"Image": "ded7cd95e059788f2586a51c275a4f151653779d6a7f4dad77c2bd34601d94e4",
|
||||||
},
|
"NetworkSettings": {
|
||||||
"Hostname": "1eb5fabf5a03",
|
"Bridge": "",
|
||||||
"Image": "summit/nginx",
|
"EndpointID": "",
|
||||||
"Labels": {
|
"Gateway": "",
|
||||||
"com.example.vendor": "Acme",
|
"GlobalIPv6Address": "",
|
||||||
"com.example.license": "GPL",
|
"GlobalIPv6PrefixLen": 0,
|
||||||
"com.example.version": "1.0"
|
"HairpinMode": false,
|
||||||
},
|
"IPAddress": "",
|
||||||
"MacAddress": "",
|
"IPPrefixLen": 0,
|
||||||
"NetworkDisabled": false,
|
"IPv6Gateway": "",
|
||||||
"OnBuild": null,
|
"LinkLocalIPv6Address": "",
|
||||||
"OpenStdin": false,
|
"LinkLocalIPv6PrefixLen": 0,
|
||||||
"StdinOnce": false,
|
"MacAddress": "",
|
||||||
"Tty": true,
|
"NetworkID": "",
|
||||||
"User": "",
|
"PortMapping": null,
|
||||||
"Volumes": null,
|
"Ports": null,
|
||||||
"WorkingDir": "",
|
"SandboxKey": "",
|
||||||
|
"SecondaryIPAddresses": null,
|
||||||
|
"SecondaryIPv6Addresses": null
|
||||||
|
},
|
||||||
|
"ResolvConfPath": "/var/lib/docker/containers/d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47/resolv.conf",
|
||||||
|
"HostnamePath": "/var/lib/docker/containers/d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47/hostname",
|
||||||
|
"HostsPath": "/var/lib/docker/containers/d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47/hosts",
|
||||||
|
"LogPath": "/var/lib/docker/containers/d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47/d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47-json.log",
|
||||||
|
"Name": "/adoring_wozniak",
|
||||||
|
"RestartCount": 0,
|
||||||
|
"Driver": "devicemapper",
|
||||||
|
"ExecDriver": "native-0.2",
|
||||||
|
"MountLabel": "",
|
||||||
|
"ProcessLabel": "",
|
||||||
|
"Volumes": {},
|
||||||
|
"VolumesRW": {},
|
||||||
|
"AppArmorProfile": "",
|
||||||
|
"ExecIDs": null,
|
||||||
|
"HostConfig": {
|
||||||
|
"Binds": null,
|
||||||
|
"ContainerIDFile": "",
|
||||||
|
"LxcConf": [],
|
||||||
|
"Memory": 0,
|
||||||
|
"MemorySwap": 0,
|
||||||
|
"CpuShares": 0,
|
||||||
|
"CpuPeriod": 0,
|
||||||
|
"CpusetCpus": "",
|
||||||
|
"CpusetMems": "",
|
||||||
|
"CpuQuota": 0,
|
||||||
|
"BlkioWeight": 0,
|
||||||
|
"OomKillDisable": false,
|
||||||
|
"Privileged": false,
|
||||||
|
"PortBindings": {},
|
||||||
|
"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
|
||||||
},
|
},
|
||||||
"Created": "2014-04-04T21:33:52.02361335Z",
|
"SecurityOpt": null,
|
||||||
"Driver": "devicemapper",
|
"ReadonlyRootfs": false,
|
||||||
"ExecDriver": "native-0.1",
|
"Ulimits": null,
|
||||||
"ExecIDs": null,
|
"LogConfig": {
|
||||||
"HostConfig": {
|
"Type": "json-file",
|
||||||
"Binds": null,
|
"Config": {}
|
||||||
"CapAdd": null,
|
},
|
||||||
"CapDrop": null,
|
"CgroupParent": ""
|
||||||
"CgroupParent": "",
|
},
|
||||||
"ContainerIDFile": "",
|
"GraphDriver": {
|
||||||
"CpuShares": 512,
|
"Name": "devicemapper",
|
||||||
"CpusetCpus": "0,1",
|
"Data": {
|
||||||
"CpusetMems": "",
|
"DeviceId": "5",
|
||||||
"Devices": [],
|
"DeviceName": "docker-253:1-2763198-d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47",
|
||||||
"Dns": null,
|
"DeviceSize": "171798691840"
|
||||||
"DnsSearch": null,
|
|
||||||
"ExtraHosts": null,
|
|
||||||
"IpcMode": "",
|
|
||||||
"Links": null,
|
|
||||||
"LogConfig": {
|
|
||||||
"Config": null,
|
|
||||||
"Type": "json-file"
|
|
||||||
},
|
|
||||||
"LxcConf": null,
|
|
||||||
"Memory": 16777216,
|
|
||||||
"MemorySwap": -1,
|
|
||||||
"NetworkMode": "",
|
|
||||||
"PidMode": "",
|
|
||||||
"PortBindings": {
|
|
||||||
"80/tcp": [
|
|
||||||
{
|
|
||||||
"HostIp": "0.0.0.0",
|
|
||||||
"HostPort": "80"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"Privileged": false,
|
|
||||||
"PublishAllPorts": false,
|
|
||||||
"ReadonlyRootfs": false,
|
|
||||||
"RestartPolicy": {
|
|
||||||
"MaximumRetryCount": 0,
|
|
||||||
"Name": ""
|
|
||||||
},
|
|
||||||
"SecurityOpt": null,
|
|
||||||
"Ulimits": null,
|
|
||||||
"VolumesFrom": null
|
|
||||||
}
|
}
|
||||||
"HostnamePath": "/var/lib/docker/containers/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b/hostname",
|
},
|
||||||
"HostsPath": "/var/lib/docker/containers/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b/hosts",
|
"Config": {
|
||||||
"ID": "1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b",
|
"Hostname": "d2cc496561d6",
|
||||||
"Image": "df53773a4390e25936f9fd3739e0c0e60a62d024ea7b669282b27e65ae8458e6",
|
"Domainname": "",
|
||||||
"LogPath": "/var/lib/docker/containers/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b-json.log",
|
"User": "",
|
||||||
"MountLabel": "",
|
"AttachStdin": true,
|
||||||
"Name": "/ecstatic_ptolemy",
|
"AttachStdout": true,
|
||||||
"NetworkSettings": {
|
"AttachStderr": true,
|
||||||
"Bridge": "docker0",
|
"ExposedPorts": null,
|
||||||
"Gateway": "172.17.42.1",
|
"Tty": true,
|
||||||
"GlobalIPv6Address": "",
|
"OpenStdin": true,
|
||||||
"GlobalIPv6PrefixLen": 0,
|
"StdinOnce": true,
|
||||||
"IPAddress": "172.17.0.2",
|
"Env": null,
|
||||||
"IPPrefixLen": 16,
|
"Cmd": [
|
||||||
"IPv6Gateway": "",
|
"bash"
|
||||||
"LinkLocalIPv6Address": "",
|
],
|
||||||
"LinkLocalIPv6PrefixLen": 0,
|
"Image": "fedora",
|
||||||
"MacAddress": "",
|
"Volumes": null,
|
||||||
"PortMapping": null,
|
"VolumeDriver": "",
|
||||||
"Ports": {
|
"WorkingDir": "",
|
||||||
"80/tcp": [
|
"Entrypoint": null,
|
||||||
{
|
"NetworkDisabled": false,
|
||||||
"HostIp": "0.0.0.0",
|
"MacAddress": "",
|
||||||
"HostPort": "80"
|
"OnBuild": null,
|
||||||
}
|
"Labels": {},
|
||||||
]
|
"Memory": 0,
|
||||||
}
|
"MemorySwap": 0,
|
||||||
},
|
"CpuShares": 0,
|
||||||
"Path": "/usr/sbin/nginx",
|
"Cpuset": ""
|
||||||
"ProcessLabel": "",
|
|
||||||
"ResolvConfPath": "/etc/resolv.conf",
|
|
||||||
"RestartCount": 0,
|
|
||||||
"State": {
|
|
||||||
"Dead": false,
|
|
||||||
"Error": "",
|
|
||||||
"ExitCode": 0,
|
|
||||||
"FinishedAt": "0001-01-01T00:00:00Z",
|
|
||||||
"OOMKilled": false,
|
|
||||||
"Paused": false,
|
|
||||||
"Pid": 858,
|
|
||||||
"Restarting": false,
|
|
||||||
"Running": true,
|
|
||||||
"StartedAt": "2014-04-04T21:33:54.16259207Z",
|
|
||||||
},
|
|
||||||
"Volumes": {},
|
|
||||||
"VolumesRW": {},
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
## Getting the IP address of a container instance
|
## Getting the IP address of a container instance
|
||||||
|
|
||||||
To get the IP address of a container use:
|
To get the IP address of a container use:
|
||||||
|
|
||||||
$ docker inspect --format='{{.NetworkSettings.IPAddress}}' 1eb5fabf5a03
|
$ docker inspect --format='{{.NetworkSettings.IPAddress}}' d2cc496561d6
|
||||||
172.17.0.2
|
172.17.0.2
|
||||||
|
|
||||||
## Listing all port bindings
|
## Listing all port bindings
|
||||||
|
@ -175,7 +176,7 @@ One can loop over arrays and maps in the results to produce simple text
|
||||||
output:
|
output:
|
||||||
|
|
||||||
$ docker inspect --format='{{range $p, $conf := .NetworkSettings.Ports}} \
|
$ docker inspect --format='{{range $p, $conf := .NetworkSettings.Ports}} \
|
||||||
{{$p}} -> {{(index $conf 0).HostPort}} {{end}}' 1eb5fabf5a03
|
{{$p}} -> {{(index $conf 0).HostPort}} {{end}}' d2cc496561d6
|
||||||
80/tcp -> 80
|
80/tcp -> 80
|
||||||
|
|
||||||
You can get more information about how to write a go template from:
|
You can get more information about how to write a go template from:
|
||||||
|
@ -186,79 +187,79 @@ http://golang.org/pkg/text/template/.
|
||||||
Use an image's ID or name (e.g., repository/name[:tag]) to get information
|
Use an image's ID or name (e.g., repository/name[:tag]) to get information
|
||||||
on it.
|
on it.
|
||||||
|
|
||||||
$ docker inspect fc1203419df2
|
$ docker inspect ded7cd95e059
|
||||||
[{
|
[{
|
||||||
"Architecture": "amd64",
|
"Id": "ded7cd95e059788f2586a51c275a4f151653779d6a7f4dad77c2bd34601d94e4",
|
||||||
"Author": "",
|
"Parent": "48ecf305d2cf7046c1f5f8fcbcd4994403173441d4a7f125b1bb0ceead9de731",
|
||||||
"Comment": "",
|
"Comment": "",
|
||||||
"Config": {
|
"Created": "2015-05-27T16:58:22.937503085Z",
|
||||||
"AttachStderr": false,
|
"Container": "76cf7f67d83a7a047454b33007d03e32a8f474ad332c3a03c94537edd22b312b",
|
||||||
"AttachStdin": false,
|
"ContainerConfig": {
|
||||||
"AttachStdout": false,
|
"Hostname": "76cf7f67d83a",
|
||||||
"Cmd": [
|
"Domainname": "",
|
||||||
"make",
|
"User": "",
|
||||||
"direct-test"
|
"AttachStdin": false,
|
||||||
],
|
"AttachStdout": false,
|
||||||
"Domainname": "",
|
"AttachStderr": false,
|
||||||
"Entrypoint": [
|
"ExposedPorts": null,
|
||||||
"/dind"
|
"Tty": false,
|
||||||
],
|
"OpenStdin": false,
|
||||||
"Env": [
|
"StdinOnce": false,
|
||||||
"PATH=/go/bin:/usr/src/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
|
"Env": null,
|
||||||
],
|
"Cmd": [
|
||||||
"ExposedPorts": null,
|
"/bin/sh",
|
||||||
"Hostname": "242978536a06",
|
"-c",
|
||||||
"Image": "c2b774c744afc5bea603b5e6c5218539e506649326de3ea0135182f299d0519a",
|
"#(nop) ADD file:4be46382bcf2b095fcb9fe8334206b584eff60bb3fad8178cbd97697fcb2ea83 in /"
|
||||||
"Labels": {},
|
],
|
||||||
"MacAddress": "",
|
"Image": "48ecf305d2cf7046c1f5f8fcbcd4994403173441d4a7f125b1bb0ceead9de731",
|
||||||
"NetworkDisabled": false,
|
"Volumes": null,
|
||||||
"OnBuild": [],
|
"VolumeDriver": "",
|
||||||
"OpenStdin": false,
|
"WorkingDir": "",
|
||||||
"StdinOnce": false,
|
"Entrypoint": null,
|
||||||
"Tty": false,
|
"NetworkDisabled": false,
|
||||||
"User": "",
|
"MacAddress": "",
|
||||||
"Volumes": null,
|
"OnBuild": null,
|
||||||
"WorkingDir": "/go/src/github.com/docker/libcontainer"
|
"Labels": {}
|
||||||
},
|
},
|
||||||
"Container": "1c00417f3812a96d3ebc29e7fdee69f3d586d703ab89c8233fd4678d50707b39",
|
"DockerVersion": "1.6.0",
|
||||||
"ContainerConfig": {
|
"Author": "Lokesh Mandvekar \u003clsm5@fedoraproject.org\u003e",
|
||||||
"AttachStderr": false,
|
"Config": {
|
||||||
"AttachStdin": false,
|
"Hostname": "76cf7f67d83a",
|
||||||
"AttachStdout": false,
|
"Domainname": "",
|
||||||
"Cmd": [
|
"User": "",
|
||||||
"/bin/sh",
|
"AttachStdin": false,
|
||||||
"-c",
|
"AttachStdout": false,
|
||||||
"#(nop) CMD [\"make\" \"direct-test\"]"
|
"AttachStderr": false,
|
||||||
],
|
"ExposedPorts": null,
|
||||||
"Domainname": "",
|
"Tty": false,
|
||||||
"Entrypoint": [
|
"OpenStdin": false,
|
||||||
"/dind"
|
"StdinOnce": false,
|
||||||
],
|
"Env": null,
|
||||||
"Env": [
|
"Cmd": null,
|
||||||
"PATH=/go/bin:/usr/src/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
|
"Image": "48ecf305d2cf7046c1f5f8fcbcd4994403173441d4a7f125b1bb0ceead9de731",
|
||||||
],
|
"Volumes": null,
|
||||||
"ExposedPorts": null,
|
"VolumeDriver": "",
|
||||||
"Hostname": "242978536a06",
|
"WorkingDir": "",
|
||||||
"Image": "c2b774c744afc5bea603b5e6c5218539e506649326de3ea0135182f299d0519a",
|
"Entrypoint": null,
|
||||||
"Labels": {},
|
"NetworkDisabled": false,
|
||||||
"MacAddress": "",
|
"MacAddress": "",
|
||||||
"NetworkDisabled": false,
|
"OnBuild": null,
|
||||||
"OnBuild": [],
|
"Labels": {}
|
||||||
"OpenStdin": false,
|
},
|
||||||
"StdinOnce": false,
|
"Architecture": "amd64",
|
||||||
"Tty": false,
|
"Os": "linux",
|
||||||
"User": "",
|
"Size": 186507296,
|
||||||
"Volumes": null,
|
"VirtualSize": 186507296,
|
||||||
"WorkingDir": "/go/src/github.com/docker/libcontainer"
|
"GraphDriver": {
|
||||||
},
|
"Name": "devicemapper",
|
||||||
"Created": "2015-04-07T05:34:39.079489206Z",
|
"Data": {
|
||||||
"DockerVersion": "1.5.0-dev",
|
"DeviceId": "3",
|
||||||
"Id": "fc1203419df26ca82cad1dd04c709cb1b8a8a947bd5bcbdfbef8241a76f031db",
|
"DeviceName": "docker-253:1-2763198-ded7cd95e059788f2586a51c275a4f151653779d6a7f4dad77c2bd34601d94e4",
|
||||||
"Os": "linux",
|
"DeviceSize": "171798691840"
|
||||||
"Parent": "c2b774c744afc5bea603b5e6c5218539e506649326de3ea0135182f299d0519a",
|
}
|
||||||
"Size": 0,
|
}
|
||||||
"VirtualSize": 613136466
|
}
|
||||||
}]
|
]
|
||||||
|
|
||||||
# HISTORY
|
# HISTORY
|
||||||
April 2014, originally compiled by William Henry (whenry at redhat dot com)
|
April 2014, originally compiled by William Henry (whenry at redhat dot com)
|
||||||
|
|
Loading…
Reference in New Issue