github.com/hustcat/docker@v1.3.3-0.20160314103604-901c67a8eeab/man/docker-inspect.1.md (about) 1 % DOCKER(1) Docker User Manuals 2 % Docker Community 3 % JUNE 2014 4 # NAME 5 docker-inspect - Return low-level information on a container or image 6 7 # SYNOPSIS 8 **docker inspect** 9 [**--help**] 10 [**-f**|**--format**[=*FORMAT*]] 11 [**-s**|**--size**] 12 [**--type**=*container*|*image*] 13 CONTAINER|IMAGE [CONTAINER|IMAGE...] 14 15 # DESCRIPTION 16 17 This displays all the information available in Docker for a given 18 container or image. By default, this will render all results in a JSON 19 array. If the container and image have the same name, this will return 20 container JSON for unspecified type. If a format is specified, the given 21 template will be executed for each result. 22 23 # OPTIONS 24 **--help** 25 Print usage statement 26 27 **-f**, **--format**="" 28 Format the output using the given Go template. 29 30 **-s**, **--size** 31 Display total file sizes if the type is container. 32 33 **--type**="*container*|*image*" 34 Return JSON for specified type, permissible values are "image" or "container" 35 36 # EXAMPLES 37 38 Get information about an image when image name conflicts with the container name, 39 e.g. both image and container are named rhel7: 40 41 $ docker inspect --type=image rhel7 42 [ 43 { 44 "Id": "fe01a428b9d9de35d29531e9994157978e8c48fa693e1bf1d221dffbbb67b170", 45 "Parent": "10acc31def5d6f249b548e01e8ffbaccfd61af0240c17315a7ad393d022c5ca2", 46 .... 47 } 48 ] 49 50 ## Getting information on a container 51 52 To get information on a container use its ID or instance name: 53 54 $ docker inspect d2cc496561d6 55 [{ 56 "Id": "d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47", 57 "Created": "2015-06-08T16:18:02.505155285Z", 58 "Path": "bash", 59 "Args": [], 60 "State": { 61 "Running": false, 62 "Paused": false, 63 "Restarting": false, 64 "OOMKilled": false, 65 "Dead": false, 66 "Pid": 0, 67 "ExitCode": 0, 68 "Error": "", 69 "StartedAt": "2015-06-08T16:18:03.643865954Z", 70 "FinishedAt": "2015-06-08T16:57:06.448552862Z" 71 }, 72 "Image": "ded7cd95e059788f2586a51c275a4f151653779d6a7f4dad77c2bd34601d94e4", 73 "NetworkSettings": { 74 "Bridge": "", 75 "SandboxID": "6b4851d1903e16dd6a567bd526553a86664361f31036eaaa2f8454d6f4611f6f", 76 "HairpinMode": false, 77 "LinkLocalIPv6Address": "", 78 "LinkLocalIPv6PrefixLen": 0, 79 "Ports": {}, 80 "SandboxKey": "/var/run/docker/netns/6b4851d1903e", 81 "SecondaryIPAddresses": null, 82 "SecondaryIPv6Addresses": null, 83 "EndpointID": "7587b82f0dada3656fda26588aee72630c6fab1536d36e394b2bfbcf898c971d", 84 "Gateway": "172.17.0.1", 85 "GlobalIPv6Address": "", 86 "GlobalIPv6PrefixLen": 0, 87 "IPAddress": "172.17.0.2", 88 "IPPrefixLen": 16, 89 "IPv6Gateway": "", 90 "MacAddress": "02:42:ac:12:00:02", 91 "Networks": { 92 "bridge": { 93 "NetworkID": "7ea29fc1412292a2d7bba362f9253545fecdfa8ce9a6e37dd10ba8bee7129812", 94 "EndpointID": "7587b82f0dada3656fda26588aee72630c6fab1536d36e394b2bfbcf898c971d", 95 "Gateway": "172.17.0.1", 96 "IPAddress": "172.17.0.2", 97 "IPPrefixLen": 16, 98 "IPv6Gateway": "", 99 "GlobalIPv6Address": "", 100 "GlobalIPv6PrefixLen": 0, 101 "MacAddress": "02:42:ac:12:00:02" 102 } 103 } 104 105 }, 106 "ResolvConfPath": "/var/lib/docker/containers/d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47/resolv.conf", 107 "HostnamePath": "/var/lib/docker/containers/d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47/hostname", 108 "HostsPath": "/var/lib/docker/containers/d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47/hosts", 109 "LogPath": "/var/lib/docker/containers/d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47/d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47-json.log", 110 "Name": "/adoring_wozniak", 111 "RestartCount": 0, 112 "Driver": "devicemapper", 113 "ExecDriver": "native-0.2", 114 "MountLabel": "", 115 "ProcessLabel": "", 116 "Mounts": [ 117 { 118 "Source": "/data", 119 "Destination": "/data", 120 "Mode": "ro,Z", 121 "RW": false 122 "Propagation": "" 123 } 124 ], 125 "AppArmorProfile": "", 126 "ExecIDs": null, 127 "HostConfig": { 128 "Binds": null, 129 "ContainerIDFile": "", 130 "Memory": 0, 131 "MemorySwap": 0, 132 "CpuShares": 0, 133 "CpuPeriod": 0, 134 "CpusetCpus": "", 135 "CpusetMems": "", 136 "CpuQuota": 0, 137 "BlkioWeight": 0, 138 "OomKillDisable": false, 139 "Privileged": false, 140 "PortBindings": {}, 141 "Links": null, 142 "PublishAllPorts": false, 143 "Dns": null, 144 "DnsSearch": null, 145 "DnsOptions": null, 146 "ExtraHosts": null, 147 "VolumesFrom": null, 148 "Devices": [], 149 "NetworkMode": "bridge", 150 "IpcMode": "", 151 "PidMode": "", 152 "UTSMode": "", 153 "CapAdd": null, 154 "CapDrop": null, 155 "RestartPolicy": { 156 "Name": "no", 157 "MaximumRetryCount": 0 158 }, 159 "SecurityOpt": null, 160 "ReadonlyRootfs": false, 161 "Ulimits": null, 162 "LogConfig": { 163 "Type": "json-file", 164 "Config": {} 165 }, 166 "CgroupParent": "" 167 }, 168 "GraphDriver": { 169 "Name": "devicemapper", 170 "Data": { 171 "DeviceId": "5", 172 "DeviceName": "docker-253:1-2763198-d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47", 173 "DeviceSize": "171798691840" 174 } 175 }, 176 "Config": { 177 "Hostname": "d2cc496561d6", 178 "Domainname": "", 179 "User": "", 180 "AttachStdin": true, 181 "AttachStdout": true, 182 "AttachStderr": true, 183 "ExposedPorts": null, 184 "Tty": true, 185 "OpenStdin": true, 186 "StdinOnce": true, 187 "Env": null, 188 "Cmd": [ 189 "bash" 190 ], 191 "Image": "fedora", 192 "Volumes": null, 193 "VolumeDriver": "", 194 "WorkingDir": "", 195 "Entrypoint": null, 196 "NetworkDisabled": false, 197 "MacAddress": "", 198 "OnBuild": null, 199 "Labels": {}, 200 "Memory": 0, 201 "MemorySwap": 0, 202 "CpuShares": 0, 203 "Cpuset": "", 204 "StopSignal": "SIGTERM" 205 } 206 } 207 ] 208 ## Getting the IP address of a container instance 209 210 To get the IP address of a container use: 211 212 $ docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' d2cc496561d6 213 172.17.0.2 214 215 ## Listing all port bindings 216 217 One can loop over arrays and maps in the results to produce simple text 218 output: 219 220 $ docker inspect --format='{{range $p, $conf := .NetworkSettings.Ports}} \ 221 {{$p}} -> {{(index $conf 0).HostPort}} {{end}}' d2cc496561d6 222 80/tcp -> 80 223 224 You can get more information about how to write a Go template from: 225 https://golang.org/pkg/text/template/. 226 227 ## Getting size information on an container 228 229 $ docker inspect -s d2cc496561d6 230 [ 231 { 232 .... 233 "SizeRw": 0, 234 "SizeRootFs": 972, 235 .... 236 } 237 ] 238 239 ## Getting information on an image 240 241 Use an image's ID or name (e.g., repository/name[:tag]) to get information 242 about the image: 243 244 $ docker inspect ded7cd95e059 245 [{ 246 "Id": "ded7cd95e059788f2586a51c275a4f151653779d6a7f4dad77c2bd34601d94e4", 247 "Parent": "48ecf305d2cf7046c1f5f8fcbcd4994403173441d4a7f125b1bb0ceead9de731", 248 "Comment": "", 249 "Created": "2015-05-27T16:58:22.937503085Z", 250 "Container": "76cf7f67d83a7a047454b33007d03e32a8f474ad332c3a03c94537edd22b312b", 251 "ContainerConfig": { 252 "Hostname": "76cf7f67d83a", 253 "Domainname": "", 254 "User": "", 255 "AttachStdin": false, 256 "AttachStdout": false, 257 "AttachStderr": false, 258 "ExposedPorts": null, 259 "Tty": false, 260 "OpenStdin": false, 261 "StdinOnce": false, 262 "Env": null, 263 "Cmd": [ 264 "/bin/sh", 265 "-c", 266 "#(nop) ADD file:4be46382bcf2b095fcb9fe8334206b584eff60bb3fad8178cbd97697fcb2ea83 in /" 267 ], 268 "Image": "48ecf305d2cf7046c1f5f8fcbcd4994403173441d4a7f125b1bb0ceead9de731", 269 "Volumes": null, 270 "VolumeDriver": "", 271 "WorkingDir": "", 272 "Entrypoint": null, 273 "NetworkDisabled": false, 274 "MacAddress": "", 275 "OnBuild": null, 276 "Labels": {} 277 }, 278 "DockerVersion": "1.6.0", 279 "Author": "Lokesh Mandvekar \u003clsm5@fedoraproject.org\u003e", 280 "Config": { 281 "Hostname": "76cf7f67d83a", 282 "Domainname": "", 283 "User": "", 284 "AttachStdin": false, 285 "AttachStdout": false, 286 "AttachStderr": false, 287 "ExposedPorts": null, 288 "Tty": false, 289 "OpenStdin": false, 290 "StdinOnce": false, 291 "Env": null, 292 "Cmd": null, 293 "Image": "48ecf305d2cf7046c1f5f8fcbcd4994403173441d4a7f125b1bb0ceead9de731", 294 "Volumes": null, 295 "VolumeDriver": "", 296 "WorkingDir": "", 297 "Entrypoint": null, 298 "NetworkDisabled": false, 299 "MacAddress": "", 300 "OnBuild": null, 301 "Labels": {} 302 }, 303 "Architecture": "amd64", 304 "Os": "linux", 305 "Size": 186507296, 306 "VirtualSize": 186507296, 307 "GraphDriver": { 308 "Name": "devicemapper", 309 "Data": { 310 "DeviceId": "3", 311 "DeviceName": "docker-253:1-2763198-ded7cd95e059788f2586a51c275a4f151653779d6a7f4dad77c2bd34601d94e4", 312 "DeviceSize": "171798691840" 313 } 314 } 315 } 316 ] 317 318 # HISTORY 319 April 2014, originally compiled by William Henry (whenry at redhat dot com) 320 based on docker.com source material and internal work. 321 June 2014, updated by Sven Dowideit <SvenDowideit@home.org.au> 322 April 2015, updated by Qiang Huang <h.huangqiang@huawei.com> 323 October 2015, updated by Sally O'Malley <somalley@redhat.com>