docker inspect
根据容器 ID 或容器名称查询容器实例详情。
命令格式
docker inspect [containerId|containerName]
参数说明
参数 | 说明 | 是否必填 |
---|---|---|
containerID | 容器 ID | containerID 和 containerName 至少需要填一个 |
containerName | 容器名称 | containerID 和 containerName 至少需要填一个 |
命令示例
示例一:根据容器 ID 查询容器实例详情。如容器 ID 为 4bb9056b38ab。
docker inspect 4bb9056b38ab
示例二:根据容器名称查询容器实例详情。如容器名称为 nginx-server。
docker inspect nginx-server [ { "Id": "8b291424877a4aeb0b2a84862e8b2645f88ba54c83f77239eaf714dcf0cd6b7b", "Created": "2023-03-29T06:06:53.198929625Z", "Path": "/docker-entrypoint.sh", "Args": [ "nginx", "-g", "daemon off;" ], "State": { "Status": "running", "Running": true, "Paused": false, "Restarting": false, "OOMKilled": false, "Dead": false, "Pid": 17159, "ExitCode": 0, "Error": "", "StartedAt": "2023-03-29T06:36:35.105913456Z", "FinishedAt": "2023-03-29T06:33:09.86393331Z" }, "Image": "sha256:0e901e68141fd02f237cf63eb842529f8a9500636a9419e3cf4fb986b8fe3d5d", "ResolvConfPath": "/var/lib/docker/containers/8b291424877a4aeb0b2a84862e8b2645f88ba54c83f77239eaf714dcf0cd6b7b/resolv.conf", "HostnamePath": "/var/lib/docker/containers/8b291424877a4aeb0b2a84862e8b2645f88ba54c83f77239eaf714dcf0cd6b7b/hostname", "HostsPath": "/var/lib/docker/containers/8b291424877a4aeb0b2a84862e8b2645f88ba54c83f77239eaf714dcf0cd6b7b/hosts", "LogPath": "/var/lib/docker/containers/8b291424877a4aeb0b2a84862e8b2645f88ba54c83f77239eaf714dcf0cd6b7b/8b291424877a4aeb0b2a84862e8b2645f88ba54c83f77239eaf714dcf0cd6b7b-json.log", "Name": "/nginx-server", "RestartCount": 0, "Driver": "overlay2", "Platform": "linux", "MountLabel": "", "ProcessLabel": "", "AppArmorProfile": "", "ExecIDs": null, "HostConfig": {}, "GraphDriver": { "Data": { "LowerDir": "/var/lib/docker/overlay2/2b7655269bc1c785f1b6cbf8b51915300ee1bf2af77b7ab54c3bba6d1e65a6fb-init/diff:/var/lib/docker/overlay2/dc67da4ce93f67debc129866e9b2c567f66d0acace7b1b676153b37ba2812d0b/diff:/var/lib/docker/overlay2/7f76deb63f04778924204d8e807bedb47e8c3a1d505f239a55a141febfeee70f/diff:/var/lib/docker/overlay2/a472fcd843d74f37b2971b41be60a2a6228dec7a7fe39cca87ba8e5278095e60/diff:/var/lib/docker/overlay2/91b51bb992c3c8758c262613c9d41f503fb2ff075292a3a2bb7154a2eba96d39/diff:/var/lib/docker/overlay2/db1880fd7bc2211fcdffcbfd057c76e9f36e077436df0fecd759e7454e16c5d7/diff:/var/lib/docker/overlay2/e4781c43477788624f91b053f6a32df15832b4c750e55152ea49e6fdd44a55a6/diff", "MergedDir": "/var/lib/docker/overlay2/2b7655269bc1c785f1b6cbf8b51915300ee1bf2af77b7ab54c3bba6d1e65a6fb/merged", "UpperDir": "/var/lib/docker/overlay2/2b7655269bc1c785f1b6cbf8b51915300ee1bf2af77b7ab54c3bba6d1e65a6fb/diff", "WorkDir": "/var/lib/docker/overlay2/2b7655269bc1c785f1b6cbf8b51915300ee1bf2af77b7ab54c3bba6d1e65a6fb/work" }, "Name": "overlay2" }, "Mounts": [], "Config": { "Hostname": "8b291424877a", "Domainname": "", "User": "", "AttachStdin": false, "AttachStdout": true, "AttachStderr": true, "ExposedPorts": { "80/tcp": {} }, "Tty": false, "OpenStdin": false, "StdinOnce": false, "Env": [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "NGINX_VERSION=1.21.6", "NJS_VERSION=0.7.3", "PKG_RELEASE=1~bullseye" ], "Cmd": [ "nginx", "-g", "daemon off;" ], "Image": "nginx:1.21", "Volumes": null, "WorkingDir": "", "Entrypoint": [ "/docker-entrypoint.sh" ], "OnBuild": null, "Labels": { "maintainer": "NGINX Docker Maintainers <docker-maint@nginx.com>" }, "StopSignal": "SIGQUIT" }, "NetworkSettings": { "Bridge": "", "SandboxID": "709037b6258acd7312ae2724ff71ead47859455195ad91a9dbfcca53b3d96219", "HairpinMode": false, "LinkLocalIPv6Address": "", "LinkLocalIPv6PrefixLen": 0, "Ports": { "80/tcp": null }, "SandboxKey": "/var/run/docker/netns/709037b6258a", "SecondaryIPAddresses": null, "SecondaryIPv6Addresses": null, "EndpointID": "782b28e2d1be920a63ec50bf325efc38783f48b49bb45d07810ce44d60677047", "Gateway": "172.17.0.1", "GlobalIPv6Address": "", "GlobalIPv6PrefixLen": 0, "IPAddress": "172.17.0.6", "IPPrefixLen": 16, "IPv6Gateway": "", "MacAddress": "02:42:ac:11:00:06", "Networks": { "bridge": { "IPAMConfig": null, "Links": null, "Aliases": null, "NetworkID": "d63ba3f616457eea16fcdc417ec8318d3f8cdc2539aebfe4a6c27f0487d22c7e", "EndpointID": "782b28e2d1be920a63ec50bf325efc38783f48b49bb45d07810ce44d60677047", "Gateway": "172.17.0.1", "IPAddress": "172.17.0.6", "IPPrefixLen": 16, "IPv6Gateway": "", "GlobalIPv6Address": "", "GlobalIPv6PrefixLen": 0, "MacAddress": "02:42:ac:11:00:06", "DriverOpts": null } } } } ]