Learn about your containers with `docker inspect`

Modified: 21 Oct 2024 22:57 UTC

You can learn a lot of information about your containers with docker inspect. Either the name or ID can be used to identify the container. The results will be a JSON array of general information.

Below is a truncated version of the JSON array received from an Nginx container:

$ docker inspect nginx01
$ [
    {
        "Id": "2054611bb39944009bcfdf2eeabd9eb4f1d191b06fa34f23863c233211f48e77",
        "Created": "2016-08-08T19:03:03.682Z",
        [...]
        "Driver": "sdc",
        "ExecDriver": "sdc-0.1",
        "HostConfig": {
            "Binds": null,
            "CapAdd": null,
            "CapDrop": null,
            "ContainerIDFile": "",
            "Devices": [],
            "Dns": [
                "8.8.8.8",
                "8.8.4.4"
            ],
            [...]
        },
        "Volumes": null,
        "VolumesRW": null,
        "RestartCount": 0,
        "HostnamePath": "/etc/hostname",
        "HostsPath": "/etc/hosts",
        "Image": "6685b215489379f00c1b399db75a4e4aa6546e4f2a3519145c14a2c7d5612be7",
        "MountLabel": "",
        "Name": "/nginx01",
        "NetworkSettings": {
            "Bridge": "eth1",
            "Gateway": "72.2.118.1",
            "IPAddress": "72.2.118.243",
            "IPPrefixLen": 23,
            "MacAddress": "90:b8:d0:62:26:63",
            "PortMapping": null,
            "Ports": {
                "443/tcp": null,
                "80/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "80"
                    }
                ]
            }
        },
        [...]
    }
]

Included in the array is low level information such as the container ID, image ID, network settings, and more. It is possible to filter a specific piece of information with Go templating or by using grep.

For example, to get just the ID of a specific container, you would run docker inspect <container name> | grep Id.

Compare that Docker command to triton instance get which tells you specific information about your containers on Triton. For example, your command results may look like this:

$ triton instance get <container name>
{
    "id": "2054611b-b399-4400-9bcf-df2eeabd9eb4",
    "name": "nginx01",
    "type": "smartmachine",
    "brand": "lx",
    "state": "running",
    "image": "77b85e3d-f205-363b-03c3-ddfa5e79192e",
    "ips": [
        "192.168.128.31",
        "72.2.118.243"
    ],
    "memory": 1024,
    "disk": 25600,
    [...]
    "primaryIp": "72.2.118.243",
    "firewall_enabled": true,
    "compute_node": "44454c4c-4400-1057-804c-b5c04f383432",
    "package": "g4-highcpu-1G",
    "dns_names": [
        "2054611b-b399-4400-9bcf-df2eeabd9eb4.inst.d9a01feb-be7d-6a32-b58d-ec4a2bf4ba7d.us-east-1.cns.mnx.io",
        "nginx01.inst.d9a01feb-be7d-6a32-b58d-ec4a2bf4ba7d.us-east-1.cns.mnx.io",
        "2054611b-b399-4400-9bcf-df2eeabd9eb4.inst.d9a01feb-be7d-6a32-b58d-ec4a2bf4ba7d.us-east-1.triton.zone",
        "nginx01.inst.d9a01feb-be7d-6a32-b58d-ec4a2bf4ba7d.us-east-1.triton.zone"
    ]
}

Although the purpose of triton instance get is the same as docker inspect, the triton instance command gives you additional details about your Docker containers including all of the network interfaces and automated DNS details from Triton CNS, the amount of memory allocated, disk space, etc. This information will help you understand and manage your instances within the context of the Triton Cloud.

Inspect your instances

To parse through that information and get more specific answers, use json. Run triton instance get <container name> | json <metadata label>. That label could by memory, package, name, or any other piece of metadata available with triton.