It is very common to perceive a docker container as a black box, you do now know what is in there, and very rightly so. That is what a container is all about.
But what happens when you want to actually finetune its deployment? What happens when you want to find out if there are multiple ports or volumes defined, in it. What are the hashes that are being used in your system?
All these can be retrieved by using the docker inspect command:
docker inspect grafana
And this is the output:
[
{
"Id": "6280c5bb41b8a5410d0d35b478e1617d77c332df503b32271cebdc5aadc68579",
"Created": "2016-07-27T17:32:56.328619446Z",
"Path": "/run.sh",
"Args": [],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 8153,
"ExitCode": 0,
"Error": "",
"StartedAt": "2016-07-27T17:32:57.239316798Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "sha256:932c5bca836b177b4f2071fd1061d8649f74fb510fe51b5e2d466a0e4856f10a",
"ResolvConfPath": "/zfspool1/docker/containers/6280c5bb41b8a5410d0d35b478e1617d77c332df503b32271cebdc5aadc68579/resolv.conf",
"HostnamePath": "/zfspool1/docker/containers/6280c5bb41b8a5410d0d35b478e1617d77c332df503b32271cebdc5aadc68579/hostname",
"HostsPath": "/zfspool1/docker/containers/6280c5bb41b8a5410d0d35b478e1617d77c332df503b32271cebdc5aadc68579/hosts",
"LogPath": "/zfspool1/docker/containers/6280c5bb41b8a5410d0d35b478e1617d77c332df503b32271cebdc5aadc68579/6280c5bb41b8a5410d0d35b478e1617d77c332df503b32271cebdc5aadc68579-json.log",
"Name": "/grafana",
"RestartCount": 0,
"Driver": "aufs",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": null,
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "default",
"PortBindings": {
"3000/tcp": [
{
"HostIp": "",
"HostPort": "3000"
}
]
},
"RestartPolicy": {
"Name": "no",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": [
"grafana-storage"
],
"CapAdd": null,
"CapDrop": null,
"Dns": [],
"DnsOptions": [],
"DnsSearch": [],
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "",
"Cgroup": "",
"Links": null,
"OomScoreAdj": 0,
"PidMode": "",
"Privileged": false,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": null,
"StorageOpt": null,
"UTSMode": "",
"UsernsMode": "",
"ShmSize": 67108864,
"ConsoleSize": [
0,
0
],
"Isolation": "",
"CpuShares": 0,
"Memory": 0,
"CgroupParent": "",
"BlkioWeight": 0,
"BlkioWeightDevice": null,
"BlkioDeviceReadBps": null,
"BlkioDeviceWriteBps": null,
"BlkioDeviceReadIOps": null,
"BlkioDeviceWriteIOps": null,
"CpuPeriod": 0,
"CpuQuota": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": [],
"DiskQuota": 0,
"KernelMemory": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": -1,
"OomKillDisable": false,
"PidsLimit": 0,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"BlkioIOps": 0,
"BlkioBps": 0,
"SandboxSize": 0
},
"GraphDriver": {
"Name": "aufs",
"Data": null
},
"Mounts": [
{
"Name": "b68a5fe8f6e8c817bfacbbd8004e2452411673bd631e09564873a58badc0ac3d",
"Source": "/zfspool1/docker/volumes/b68a5fe8f6e8c817bfacbbd8004e2452411673bd631e09564873a58badc0ac3d/_data",
"Destination": "/etc/grafana",
"Driver": "local",
"Mode": "",
"RW": true,
"Propagation": ""
},
{
"Source": "/zfspool1/grafana-volume",
"Destination": "/var/lib/grafana",
"Mode": "",
"RW": true,
"Propagation": "rprivate"
},
{
"Name": "ac220948e55e4e65ac9905b480bf1150aa8732a0ab6b094a8269032921478775",
"Source": "/zfspool1/docker/volumes/ac220948e55e4e65ac9905b480bf1150aa8732a0ab6b094a8269032921478775/_data",
"Destination": "/var/lib/grafana/plugins",
"Driver": "local",
"Mode": "",
"RW": true,
"Propagation": ""
},
{
"Name": "7be07c6927bbe12d0957a05a8bf3284a6e10c0ec9152646b85c2583e47a2ac6e",
"Source": "/zfspool1/docker/volumes/7be07c6927bbe12d0957a05a8bf3284a6e10c0ec9152646b85c2583e47a2ac6e/_data",
"Destination": "/var/log/grafana",
"Driver": "local",
"Mode": "",
"RW": true,
"Propagation": ""
}
],
"Config": {
"Hostname": "6280c5bb41b8",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"3000/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Cmd": null,
"Image": "grafana/grafana",
"Volumes": {
"/etc/grafana": {},
"/var/lib/grafana": {},
"/var/lib/grafana/plugins": {},
"/var/log/grafana": {}
},
"WorkingDir": "",
"Entrypoint": [
"/run.sh"
],
"OnBuild": null,
"Labels": {}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "121cb533502a3613ed086db64b3291c6dcaf2808fa97499c5bd1aac95a913593",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"3000/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "3000"
}
]
},
"SandboxKey": "/var/run/docker/netns/121cb533502a",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "bd06a65e45743a62d86509ff4ec49b38f78e8c23c5dc45c74c3cdfb98c840c21",
"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": "8312143de9ee482776c4b923b71d695687244fc9ac28ec8d151bd7678a9240ae",
"EndpointID": "bd06a65e45743a62d86509ff4ec49b38f78e8c23c5dc45c74c3cdfb98c840c21",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:02"
}
}
}
}
]