Rate This Document
Findability
Accuracy
Completeness
Readability

Container Metadata

You can run the inspect command provided by Docker to view container details. In the following command, ${index} indicates the ID of the started instance.

1
# docker inspect kbox_${index}

After the preceding command is executed, all metadata information of the container is returned in JSON array format. In most cases, if you only need to obtain a specific piece of data about the container, you can extract the required data from the JSON data. For example, to obtain the IP address of the container, run the following command: Table 1 lists the commands for querying other container data.

1
# docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' kbox_${index}

The IP address of the container is displayed in the command output.

Table 1 Common commands for querying container data

Item

Command

Obtaining the CPU bound to a container

# docker inspect --format='{{.Name }} {{ .HostConfig.CpusetCpus }}' kbox_${index}

Obtaining the memory size (in bytes) of a container

# docker inspect --format='{{.Name }} {{ .HostConfig.Memory }}' kbox_${index}