Docker Config Reference (docker inspect)
We go over many examples of using docker info to obtain statistics on a container
Example 1
docker inspect myrunningcontainer
This command retrieves detailed metadata about the running container "myrunningcontainer" in JSON format, encompassing configuration, state, network settings, and resource usage, which is essential for comprehensive runtime analysis in operational environments.
Example 2
docker inspect --format '{{.State.Status}}' stoppedcontainer
This command extracts and displays only the status (e.g., "exited") of the stopped container "stoppedcontainer" using Go template formatting, facilitating quick state verification in automation scripts.
Example 3
docker inspect --type=image nginx:latest
This command inspects the "nginx:latest" image, specifying the type to ensure image-specific details like layers, architecture, and environment variables are returned, aiding in image compatibility assessments.
Example 4
docker inspect a1b2c3d4e5f6
This command inspects a container by its partial ID "a1b2c3d4e5f6", providing flexibility when full names are unavailable, and outputs complete JSON metadata for diagnostic purposes.
Example 5
docker inspect --format '{{json .NetworkSettings}}' netcont
This command formats the output to show only the network settings of "netcont" in JSON, which is valuable for troubleshooting connectivity issues in networked applications.
Example 6
docker inspect --size datavolcont
This command inspects the container "datavolcont" and includes filesystem size information (--size), enabling storage usage evaluation for data-intensive workloads.
Example 7
docker inspect --type=network mybridge
This command inspects the custom bridge network "mybridge", detailing subnet, gateway, and attached containers, supporting network configuration reviews.
Example 8
docker inspect --format '{{.Config.Hostname}}' hostcont
This command extracts the hostname from the configuration of "hostcont", assisting in verifying container identity in clustered setups.
Example 9
docker inspect --type=volume myvolume
This command inspects the named volume "myvolume", providing mountpoint, driver, and label details for persistent storage management.
Example 10
docker inspect --format '{{.State.Pid}}' proccont
This command displays the process ID (PID) of the main process in "proccont", which is useful for host-level process monitoring or integration with system tools.
Example 11
docker inspect f6e5d4c3b2a1
This command inspects a container by its full ID "f6e5d4c3b2a1", ensuring precise targeting in environments with multiple similar objects.
Example 12
docker inspect --format '{{json .Mounts}}' mountcont
This command outputs the mount points of "mountcont" in JSON, aiding in volume and bind mount verification for data persistence.
Example 13
docker inspect --type=plugin myplugin
This command inspects the installed plugin "myplugin", detailing its configuration and capabilities for extensibility checks.
Example 14
docker inspect --format '{{.LogPath}}' logcont
This command retrieves the log file path for "logcont", supporting custom log analysis or rotation configurations.
Example 15
docker inspect --type=secret mysecret
This command inspects the Swarm secret "mysecret", providing metadata like labels and creation time for security auditing in clustered environments.
Example 16
docker inspect --format '{{.Args}}' argcont
This command displays the command-line arguments of "argcont", verifying runtime parameters in application launches.
Example 17
docker inspect --type=config myconfig
This command inspects the Swarm config "myconfig", detailing its content and labels for configuration management.
Example 18
docker inspect --format '{{json .HostConfig}}' hostconfigcont
This command outputs the host configuration of "hostconfigcont" in JSON, including resource limits and security options for performance tuning.
Example 19
docker inspect --type=node swarmnode
This command inspects the Swarm node "swarmnode", providing availability, role, and resource details for cluster administration.
Example 20
docker inspect --format '{{.RestartCount}}' restartcont
This command shows the restart count for "restartcont", monitoring stability in high-availability setups.
Example 21
docker inspect --type=task myswarmtask
This command inspects the Swarm task "myswarmtask", detailing its state, node assignment, and logs for orchestration troubleshooting.
Example 22
docker inspect --format '{{.Health.Status}}' healthcont
This command extracts the health status of "healthcont", verifying application readiness in health-checked services.
Example 23
docker inspect --type=service myservice
This command inspects the Swarm service "myservice", providing replica count, update status, and endpoint details for service management.
Example 24
docker inspect --format '{{json .ExecIDs}}' execcont
This command lists exec instance IDs in "execcont", tracking attached sessions for multi-user debugging.
Example 25
docker inspect 1234567890ab
This command inspects a container by shortened ID "1234567890ab", for quick checks in console outputs from docker ps.
Example 26
docker inspect --size --format '{{.SizeRw}}' sizecont
This command displays the read-write layer size of "sizecont" with --size, assessing data growth in running containers.
Example 27
docker inspect --type=plugin --format '{{.Config.Interface.Types}}' netplugin
This command formats the interface types of the network plugin "netplugin", verifying plugin compatibility.
Example 28
docker inspect --format '{{.GraphDriver.Name}}' drivercont
This command shows the graph driver for "drivercont", diagnosing storage backend configurations.
Example 29
docker inspect --type=volume --format '{{.Mountpoint}}' datavol
This command extracts the host mountpoint of volume "datavol", for direct file access on the host.
Example 30
docker inspect --format '{{json .ResolvConfPath}}' resolvcont
This command outputs the resolv.conf path of "resolvcont" in JSON, verifying DNS configurations.