Docker Inspect

Docker Docker

As soon as you get familiar with listing Docker containers and starting containers or stopping containers, you’ll probably get curious about learning a little more. Docker has a great command for obtaining low level configuration details about containers: docker inspect.

Docker Inspect features

I find the following to be most useful when using docker inspect to look at one of the running containers:

  • long form container ID and timestamp when it was created
  • current status (really useful even if container is stopped – will show you why)
  • Docker image info
  • Filesystem binds and volume info, mounts
  • environment variables – this is where a lot of usernames/passwords will be found – automation comes at a cost to security
  • command line parameters passed into the container
  • network configuration: IP address and gateway, secondary addresses for IPv4 and IPv6

Docker Inspect output

Here’s a fragment of the docker inspect output for a MariaDB container on one of my hosts:

[email protected]:~ # docker inspect c74010b06784
[
{
"Id": "c74010b06784ee04976239fb6dc08062b6f5f9ea6ce3e67bd2c876365986910c",
"Created": "2019-02-04T12:41:34.958272492Z",
"Path": "docker-entrypoint.sh",
"Args": [
"--character-set-server=utf8",
"--collation-server=utf8_bin",
"--transaction-isolation=READ-COMMITTED"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 21868,
"ExitCode": 0,
"Error": "",
"StartedAt": "2019-02-26T22:30:33.060964954Z",
"FinishedAt": "2019-02-26T21:43:52.895816071Z"
},
"Image": "sha256:901583bfdf5a129ba68b033c989dab7f10d2a9235c3a2093ad16f9ac979ac9f9",
"ResolvConfPath": "/var/lib/docker/containers/c74010b06784ee04976239fb6dc08062b6f5f9ea6ce3e67bd2c876365986910c/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/c74010b06784ee04976239fb6dc08062b6f5f9ea6ce3e67bd2c876365986910c/hostname",
"HostsPath": "/var/lib/docker/containers/c74010b06784ee04976239fb6dc08062b6f5f9ea6ce3e67bd2c876365986910c/hosts",
"LogPath": "/var/lib/docker/containers/c74010b06784ee04976239fb6dc08062b6f5f9ea6ce3e67bd2c876365986910c/c74010b06784ee04976239fb6dc08062b6f5f9ea6ce3e67bd2c876365986910c-json.log",
"Name": "/db",
"RestartCount": 0,
"Driver": "devicemapper",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": [
"/storage/docker/db/datadir:/var/lib/mysql",
"/storage/docker/db/conf.d:/etc/mysql/conf.d"
],
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "confluencenet",
"PortBindings": {},
"RestartPolicy": {
"Name": "no",
"MaximumRetryCount": 0
},
...

See Also




Keep Learning with Me

Follow me on Facebook and Twitter or jump into Telegram chat!:
I'm using Brave browser
Give it a try, it's awesome: Brave Browser
IT Consultancy
I'm a principal consultant with Tech Stack Solutions. I help with cloud architectrure, AWS deployments and automated management of Unix/Linux infrastructure. Get in touch!

Recent Tweets