Docker Inspect Command
[Docker Command Manual](#)
* * *
The `docker inspect` command is used to retrieve detailed information about Docker objects (containers, images, volumes, networks, etc.).
The `docker inspect` command returns detailed information in JSON format, which can help users understand the configuration and status of an object.
### Syntax
docker inspect NAME|ID [NAME|ID...]
OPTIONS Description:
* **`-f, --format`**: Format the output using Go template syntax.
* **`--type`**: Return information for a specific type of object (optional types: `container`, `image`, `network`, `volume`).
### Examples
**1. Inspect a container**
docker inspect my_container
Returns detailed information about the `my_container` container.
**2. Inspect an image**
docker inspect my_image
Returns detailed information about the `my_image` image.
**3. Inspect a volume**
docker inspect my_volume
Returns detailed information about the `my_volume` volume.
**4. Inspect a network**
docker inspect my_network
Returns detailed information about the `my_network` network.
**5. Formatted output**
docker inspect --format '{{ .State.Running }}' my_container
Returns the running status of the `my_container` container, formatted as a boolean value.
**6. Inspect multiple objects**
docker inspect my_container my_image
Returns detailed information about the `my_container` container and the `my_image` image.
### Example Output
Container information:
docker inspect my_container
Output:
[ { "Id": "d2f5e3f19a6a", "Created": "2024-07-23T00:00:00Z", "Path": "bash", "Args": [], "State": { "Status": "running", "Running": true, "Paused": false, "Restarting": false, "OOMKilled": false, "Dead": false, "Pid": 12345, "ExitCode": 0, "Error": "", "StartedAt": "2024-07-23T00:00:00Z", "FinishedAt": "0001-01-01T00:00:00Z" }, "Image": "sha256:abc123", "ResolvConfPath": "/var/lib/docker/containers/d2f5e3f19a6a/resolv.conf", "HostnamePath": "/var/lib/docker/containers/d2f5e3f19a6a/hostname", "HostsPath": "/var/lib/docker/containers/d2f5e3f19a6a/hosts", "LogPath": "/var/lib/docker/containers/d2f5e3f19a6a/d2f5e3f19a6a-json.log", "Name": "/my_container", "RestartCount": 0, "Driver": "overlay2", "Platform": "linux", "MountLabel": "", "ProcessLabel": "", "AppArmorProfile": "", "ExecIDs": null, "HostConfig": { "Binds": null, "ContainerIDFile": "", "LogConfig": { "Type": "json-file", "Config": {} }, "NetworkMode": "default", "PortBindings": {}, "RestartPolicy": { "Name": "no", "MaximumRetryCount": 0 }, "AutoRemove": false, "VolumeDriver": "", "VolumesFrom": null, "CapAdd": null, "CapDrop": null, "Dns": [], "DnsOptions": [], "DnsSearch": [], "ExtraHosts": null, "GroupAdd": null, "IpcMode": "private", "Cgroup": "", "Links": null, "OomScoreAdj": 0, "PidMode": "", "Privileged": false, "PublishAllPorts": false, "ReadonlyRootfs": false, "SecurityOpt": null, "UTSMode": "", "UsernsMode": "", "ShmSize": 67108864, "Runtime": "runc", "ConsoleSize": [ 0, 0 ], "Isolation": "", "CpuShares": 0, "Memory": 0, "NanoCpus": 0, "CgroupParent": "", "BlkioWeight": 0, "BlkioWeightDevice": null, "BlkioDeviceReadBps": null, "BlkioDeviceWriteBps": null, "BlkioDeviceReadIOps": null, "BlkioDeviceWriteIOps": null, "CpuPeriod": 0, "CpuQuota": 0, "CpuRealtimePeriod": 0, "CpuRealtimeRuntime": 0, "CpusetCpus": "", "CpusetMems": "", "Devices": null, "DiskQuota": 0, "KernelMemory": 0, "MemoryReservation": 0, "MemorySwap": 0, "MemorySwappiness": null, "OomKillDisable": false, "PidsLimit": null, "Ulimits": null, "CpuCount": 0, "CpuPercent": 0, "IOMaximumIOps": 0, "IOMaximumBandwidth": 0, "Mounts": [], "MaskedPaths": [ "/proc/asound", "/proc/acpi", "/proc/kcore", "/proc/keys", "/proc/latency_stats", "/proc/timer_list", "/proc/timer_stats", "/proc/sched_debug", "/proc/scsi", "/sys/firmware" ], "ReadonlyPaths": [ "/proc/bus", "/proc/fs", "/proc/irq", "/proc/sys", "/proc/sysrq-trigger" ] }, "GraphDriver": { "Data": { "LowerDir": "/var/lib/docker/overlay2/l/abc123/diff", "MergedDir": "/var/lib/docker/overlay2/merged", "UpperDir": "/var/lib/docker/overlay2/upper", "WorkDir": "/var/lib/docker/overlay2/work" }, "Name": "overlay2" }, "Mounts": [], "Config": { "Hostname": "d2f5e3f19a6a", "Domainname": "", "User": "", "AttachStdin": false, "AttachStdout": false, "AttachStderr": false, "ExposedPorts": {}, "Tty": false, "OpenStdin": false, "StdinOnce": false, "Env": [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" ], "Cmd": , "Image": "ubuntu", "Volumes": null, "WorkingDir": "", "Entrypoint": null, "OnBuild": null, "Labels": {} }, "NetworkSettings": { "Bridge": "", "SandboxID": "abc123", "HairpinMode": false, "LinkLocalIPv6Address": "", "LinkLocalIPv6PrefixLen": 0, "Ports": {}, "SandboxKey": "/var/run/docker/netns/abc123", "SecondaryIPAddresses": null, "SecondaryIPv6Addresses": null, "EndpointID": "abc123", "Gateway": "172.17.0.1", "GlobalIPv6Address": "", "GlobalIPv6PrefixLen": 0, "IPAddress": "172.17.0.2", "IPPrefixLen": 16, "IPv6Gateway": "", "MacAddress": "02:42:ac:11:00:02", "Networks": { "bridge": { "IPAMConfig": null, "Links": null, "Aliases": null, "NetworkID": "abc123", "EndpointID": "abc123", "Gateway": "172.17.0.1", "IPAddress": "172.17.0.2", "IPPrefixLen": 16, "IPv6Gateway": "", "GlobalIPv6Address": "", "GlobalIPv6PrefixLen": 0, "MacAddress": "02:42:ac:11:00:02", "DriverOpts": null } } } }]
### Use Cases
* **Debugging containers**: Retrieve detailed configuration information of a container for debugging and troubleshooting.
* **Viewing network configuration**: Check the network configuration of a container to understand its network connection status.
* **Monitoring resources**: Obtain resource configuration and usage information of a container for resource management and monitoring.
* **Script automation**: Use `docker inspect` in automation scripts to get detailed information about objects for subsequent operations.
The `docker inspect` command is one of the most powerful and practical commands in Docker, allowing users to retrieve detailed information about containers, images, volumes, networks, and other objects. By using this command, users can gain deep insights into and manage the configuration and status of Docker objects, meeting various debugging, monitoring, and management needs.
* * Docker Command Manual](#)
YouTip