docker inspect
Table of Contents:
Command Name:
docker inspect
Description:
Return low-level information on Docker objects.
This means it give more details of particular docker object like image, container, network, config etc.
Syntax:
easywhatis$ docker inspect --help
Usage: docker inspect [OPTIONS] NAME|ID [NAME|ID...]
Return low-level information on Docker objects
Options:
-f, --format string Format the output using the given Go template
-s, --size Display total file sizes if the type is container
--type string Return JSON for specified type
easywhatis$
Example:
Show details about default context:
easywhatis$ docker context ls
NAME DESCRIPTION DOCKER ENDPOINT KUBERNETES ENDPOINT ORCHESTRATOR
default * Current DOCKER_HOST based configuration unix:///var/run/docker.sock swarm
easywhatis$ docker context inspect default
[
{
"Name": "default",
"Metadata": {
"StackOrchestrator": "swarm"
},
"Endpoints": {
"docker": {
"Host": "unix:///var/run/docker.sock",
"SkipTLSVerify": false
}
},
"TLSMaterial": {},
"Storage": {
"MetadataPath": "\u003cIN MEMORY\u003e",
"TLSPath": "\u003cIN MEMORY\u003e"
}
}
]
easywhatis$
Show details about ubuntu image:
easywhatis$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest ed21b7a8aee9 12 days ago 127MB
ubuntu latest 4e5021d210f6 3 weeks ago 64.2MB
busybox latest 83aa35aa1c79 4 weeks ago 1.22MB
easywhatis$ docker image inspect ubuntu
[
{
"Id": "sha256:4e5021d210f65ebe915670c7089120120bc0a303b90208592851708c1b8c04bd",
"RepoTags": [
"ubuntu:latest"
],
"RepoDigests": [
"ubuntu@sha256:bec5a2727be7fff3d308193cfde3491f8fba1a2ba392b7546b43a051853a341d"
],
"Parent": "",
"Comment": "",
"Created": "2020-03-20T19:20:22.835345724Z",
"Container": "f35b3af588999f5c47b8132845d7e6c3a220cedac21a8dada926f41de36eef55",
"ContainerConfig": {
"Hostname": "f35b3af58899",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Cmd": [
"/bin/sh",
"-c",
"#(nop) ",
"CMD [\"/bin/bash\"]"
],
"ArgsEscaped": true,
"Image": "sha256:257f42741ca08b6d23bb7cc030bb3ce32278879eb87d1f7c8195ddf9057807cb",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": {}
},
"DockerVersion": "18.09.7",
"Author": "",
"Config": {
"Hostname": "",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Cmd": [
"/bin/bash"
],
"ArgsEscaped": true,
"Image": "sha256:257f42741ca08b6d23bb7cc030bb3ce32278879eb87d1f7c8195ddf9057807cb",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": null
},
"Architecture": "amd64",
"Os": "linux",
"Size": 64205678,
"VirtualSize": 64205678,
"GraphDriver": {
"Data": {
"LowerDir": "/var/lib/docker/overlay2/2d4502ff56d090bb612cad361ee6605af7a855a14eb70ea2956b4f42cc4099bd/diff:/var/lib/docker/overlay2/ee66f43479dd0165c1550e98ed03d68d8522b97fc55b16ca9f3b89f9d07737c0/diff:/var/lib/docker/overlay2/03bbc3625630597b8bd267c2404fb4ce85342608f8bef7e391647922d7c4b699/diff",
"MergedDir": "/var/lib/docker/overlay2/e6f343a5300452023bb2200c779f9e7c588d0b384dfdf61bb71744720906f11b/merged
",
"UpperDir": "/var/lib/docker/overlay2/e6f343a5300452023bb2200c779f9e7c588d0b384dfdf61bb71744720906f11b/diff",
"WorkDir": "/var/lib/docker/overlay2/e6f343a5300452023bb2200c779f9e7c588d0b384dfdf61bb71744720906f11b/work"
},
"Name": "overlay2"
},
"RootFS": {
"Type": "layers",
"Layers": [
"sha256:c8be1b8f4d60d99c281fc2db75e0f56df42a83ad2f0b091621ce19357e19d853",
"sha256:977183d4e9995d9cd5ffdfc0f29e911ec9de777bcb0f507895daa1068477f76f",
"sha256:6597da2e2e52f4d438ad49a14ca79324f130a9ea08745505aa174a8db51cb79d",
"sha256:16542a8fc3be1bfaff6ed1daa7922e7c3b47b6c3a8d98b7fca58b9517bb99b75"
]
},
"Metadata": {
"LastTagTime": "0001-01-01T00:00:00Z"
}
}
]
easywhatis$
Inspect the ubuntu container:
easywhatis$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a5bb226d1850 ubuntu "bash" 5 hours ago Up 5 hours eloquent_knuth
easywhatis$ docker container inspect a5bb226d1850
[
{
"Id": "a5bb226d185066ff331b3ca4b82825785d3fa4da18cba00993045c823f92db90",
"Created": "2020-04-12T06:50:37.869910578Z",
"Path": "bash",
"Args": [],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 1763,
"ExitCode": 0,
"Error": "",
"StartedAt": "2020-04-12T06:51:34.1746633Z",
"FinishedAt": "2020-04-12T06:51:16.812326338Z"
},
"Image": "sha256:4e5021d210f65ebe915670c7089120120bc0a303b90208592851708c1b8c04bd",
"ResolvConfPath": "/var/lib/docker/containers/a5bb226d185066ff331b3ca4b82825785d3fa4da18cba00993045c823f92db90/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/a5bb226d185066ff331b3ca4b82825785d3fa4da18cba00993045c823f92db90/hostname",
"HostsPath": "/var/lib/docker/containers/a5bb226d185066ff331b3ca4b82825785d3fa4da18cba00993045c823f92db90/hosts",
"LogPath": "/var/lib/docker/containers/a5bb226d185066ff331b3ca4b82825785d3fa4da18cba00993045c823f92db90/a5bb226d185066ff331b3ca4b82825785d3fa4da18cba00993045c823f92db90-json.log",
"Name": "/eloquent_knuth",
"RestartCount": 0,
"Driver": "overlay2",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": null,
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "default",
"PortBindings": {},
"RestartPolicy": {
"Name": "no",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"CapAdd": null,
"CapDrop": null,
"Capabilities": null,
"Dns": [],
"DnsOptions": [],
"DnsSearch": [],
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "private",
"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": 104857600,
"NanoCpus": 0,
"CgroupParent": "",
"BlkioWeight": 0,
"BlkioWeightDevice": [],
"BlkioDeviceReadBps": null,
"BlkioDeviceWriteBps": null,
"BlkioDeviceReadIOps": null,
"BlkioDeviceWriteIOps": null,
"CpuPeriod": 0,
"CpuQuota": 0,
"CpuRealtimePeriod": 0,
"CpuRealtimeRuntime": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": [],
"DeviceCgroupRules": null,
"DeviceRequests": null,
"KernelMemory": 0,
"KernelMemoryTCP": 0,
"MemoryReservation": 0,
"MemorySwap": 209715200,
"MemorySwappiness": null,
"OomKillDisable": false,
"PidsLimit": null,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0,
"MaskedPaths": [
"/proc/asound",
"/proc/acpi",
"/proc/kcore",
"/proc/keys",
"/proc/latency_stats",
"/proc/timer_list",
"/proc/timer_stats",
"/proc/sched_debug",
"/proc/scsi",
"/sys/firmware"
],
"ReadonlyPaths": [
"/proc/bus",
"/proc/fs",
"/proc/irq",
"/proc/sys",
"/proc/sysrq-trigger"
]
},
"GraphDriver": {
"Data": {
"LowerDir": "/var/lib/docker/overlay2/9ebcf854c3e87acf4c612b0266177453d8e764bda8ab177e0bbb9704164d99b8-init/diff:/var/lib/docker/overlay2/e6f343a5300452023bb2200c779f9e7c588d0b384dfdf61bb71744720906f11b/diff:/var/lib/docker/overlay2/2d4502ff56d090bb612cad361ee6605af7a855a14eb70ea2956b4f42cc4099bd/diff:/var/lib/docker/overlay2/ee66f43479dd0165c1550e98ed03d68d8522b97fc55b16ca9f3b89f9d07737c0/diff:/var/lib/docker/overlay2/03bbc3625630597b8bd267c2404fb4ce85342608f8bef7e391647922d7c4b699/diff",
"MergedDir": "/var/lib/docker/overlay2/9ebcf854c3e87acf4c612b0266177453d8e764bda8ab177e0bbb9704164d99b8/merged",
"UpperDir": "/var/lib/docker/overlay2/9ebcf854c3e87acf4c612b0266177453d8e764bda8ab177e0bbb9704164d99b8/diff",
"WorkDir": "/var/lib/docker/overlay2/9ebcf854c3e87acf4c612b0266177453d8e764bda8ab177e0bbb9704164d99b8/work"
},
"Name": "overlay2"
},
"Mounts": [],
"Config": {
"Hostname": "a5bb226d1850",
"Domainname": "",
"User": "",
"AttachStdin": true,
"AttachStdout": true,
"AttachStderr": true,
"Tty": true,
"OpenStdin": true,
"StdinOnce": true,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Cmd": [
"bash"
],
"Image": "ubuntu",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": {}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "6cef86cfa1708b77415d9d1b657a7902ff2353562ddd970b58501c9b5fa2c6e6",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {},
"SandboxKey": "/var/run/docker/netns/6cef86cfa170",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "f666b646dcebe65314005997e51e363ddb003ae9e009eb7966c7f5e2b30be354",
"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": "7d5e21a978525f7b70a6eb15e98ccc1026137a34531e5e5c5f20e18852621703",
"EndpointID": "f666b646dcebe65314005997e51e363ddb003ae9e009eb7966c7f5e2b30be354",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:02",
"DriverOpts": null
}
}
}
}
]
easywhatis$