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