Bootstrap FreeKB - Docker - Display container details using the docker inspect container command
Docker - Display container details using the docker inspect container command

Updated:   |  Docker articles

This assumes you have installed Docker on Linux and Docker is running

A Docker image contains the code used to create a Docker container, such as creating a Nginx web server, or a mySQL server, or a home grown app, and the list goes on. In this way, an image is like a template used to create a container. An image is kind of like a virtual machine, but much more light weight, using significantly less storage a memory (containers are usually megabytes in size).

 

The docker container ls command will return the containers that have been created.

docker container ls

 

Which will return something like this.

CONTAINER ID     IMAGE              COMMAND                 CREATED         STATUS     PORTS     NAMES
d937372c09ab9    b939aa938add9913   "/docker-entrypoin..."  6 minutes ago   Created              my-container

 

The docker inspect command followed by the name or ID of a container can be used to return JSON with many more details for a container.

docker inspect my-container

 

Something like this should be returned.

[
    {
        "Id": "sha256:bb9636231c3d675986bcd1615b3de5a05d582b7536b6b3ea057d36aa92d7a7c4",
        "RepoTags": [],
        "RepoDigests": [
            "server1.example.com/foo@sha256:eb524021e92ac2fd783ed4319ce65858f04b65397476a7442a2e88f919d6d66e"
        ],
        "Parent": "",
        "Comment": "",
        "Created": "2019-10-19T13:04:50.398053606Z",
        "Container": "a5edadcd946b60d4629a83102bad388278d6ba0f509be52938c5a9b9324c0c59",
        "ContainerConfig": {
            "Hostname": "a5edadcd946b",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "1337/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "NODE_VERSION=10.16.3",
                "YARN_VERSION=1.17.3"
            ],
            "Cmd": [
                "/bin/sh",
                "-c",
                "#(nop) ",
                "ENTRYPOINT [\"/app/start.sh\"]"
            ],
            "ArgsEscaped": true,
            "Image": "sha256:45f8689b5a5eb4ee37a7465b58a107a52bfd2573d30cb46a5a8d8141dbe85af9",
            "Volumes": {
                "/app/foo": {}
            },
            "WorkingDir": "/app",
            "Entrypoint": [
                "/app/start.sh"
            ],
            "OnBuild": null,
            "Labels": {}
        },
        "DockerVersion": "18.03.1-ee-3",
        "Author": "",
        "Config": {
            "Hostname": "",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "1337/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "NODE_VERSION=10.16.3",
                "YARN_VERSION=1.17.3"
            ],
            "Cmd": null,
            "ArgsEscaped": true,
            "Image": "sha256:45f8689b5a5eb4ee37a7465b58a107a52bfd2573d30cb46a5a8d8141dbe85af9",
            "Volumes": {
                "/app/foo": {}
            },
            "WorkingDir": "/app",
            "Entrypoint": [
                "/app/start.sh"
            ],
            "OnBuild": null,
            "Labels": null
        },
        "Architecture": "amd64",
        "Os": "linux",
        "Size": 398333473,
        "VirtualSize": 398333473,
        "GraphDriver": {
            "Data": {
                "LowerDir": "/opt/docker/overlay2/4862b6eecfd7848cb1497777819945e25a18f6f5e5b23985703f46be5ee3ba73/diff:/opt/docker/overlay2/9fd0936592f72bd483ce069ae4eb262eec547f786aa253f05b16a8c9c6a15f59/diff:/opt/docker/overlay2/dc0bc87ac0d27e04dad780fe5ba94d96cbeed9642dc1783f1ddfb67fb4fb4c7a/diff:/opt/docker/overlay2/e319af6aae335515ed74a0052994581c16dfd0c43e77140719567d2b0590228b/diff:/opt/docker/overlay2/82c3621f20dd21952a77c15d2f17626a0eee2ba9cf3ff9a1e7c214c3a5b129dc/diff",
                "MergedDir": "/opt/docker/overlay2/b0aa6b7d3fab4f7d208b4cb41a0796e05113f23b082a0ae84de79aa40571d4cc/merged",
                "UpperDir": "/opt/docker/overlay2/b0aa6b7d3fab4f7d208b4cb41a0796e05113f23b082a0ae84de79aa40571d4cc/diff",
                "WorkDir": "/opt/docker/overlay2/b0aa6b7d3fab4f7d208b4cb41a0796e05113f23b082a0ae84de79aa40571d4cc/work"
            },
            "Name": "overlay2"
        },
        "RootFS": {
            "Type": "layers",
            "Layers": [
                "sha256:f1b5933fe4b5f49bbe8258745cf396afe07e625bdab3168e364daf7c956b6b81",
                "sha256:a3b85ad42b98d38a269880cc23d842bd267a630ab8554c032613ce6d9ba2476f",
                "sha256:77306e58a4bd17b11d4151957d5ae677480e01e3a5db7797d1c53a7313c9c37e",
                "sha256:dd108d5734de5775b9d4bdb550feb3133fd0ad6cbc18d5dbba65032a24cc5af2",
                "sha256:b42674e8bb42cbf1599b64767a533027a5373a9ebf27195f9a6390b0d4f0749e",
                "sha256:d45c85bc3fb1f7f9b96acbce843352272e7e29ce48a8c7b56d22122221dd0888"
            ]
        },
        "Metadata": {
            "LastTagTime": "0001-01-01T00:00:00Z"
        }
    }
]

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter ae7e08 in the box below so that we can be sure you are a human.