docker container inspect 使用详解

1、Command Help

[root@Tang-6 ~]# docker container inspect --help

Usage:	docker container inspect [OPTIONS] CONTAINER [CONTAINER...]

Display detailed information on one or more containers

Options:
  -f, --format string   Format the output using the given Go template
  -s, --size            Display total file sizes

2、Format the output using the given Go template

[root@Tang-6 ~]# docker container inspect mybox1
"NetworkSettings": {
            "Bridge": "",
            "SandboxID": "ae40c133dea7cfba1e4cdde9e154d4a14990c271f49cbd95b07634ef80a7758d",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {},
            "SandboxKey": "/var/run/docker/netns/ae40c133dea7",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "bf5fcd8ca60e049eccbd2bfd1edd51a5e03e9b59dcefd00f0e99369bacf28d9e",
            "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": "c36a83a8953298c51cb097462e0b638e8f3aeacf6702e0248d31e3b4ee969d65",
                    "EndpointID": "bf5fcd8ca60e049eccbd2bfd1edd51a5e03e9b59dcefd00f0e99369bacf28d9e",
                    "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
                }
            }
        }
    }
]
[root@Tang-6 ~]# docker container inspect -f {{.NetworkSettings.Networks.bridge.IPAddress}} mybox1
172.17.0.2
[root@Tang-6 ~]# docker container inspect -f {{.NetworkSettings.Networks.bridge.Gateway}} mybox1
172.17.0.1
发布了158 篇原创文章 · 获赞 7 · 访问量 9743

猜你喜欢

转载自blog.csdn.net/weixin_44983653/article/details/103216999