docker机器检查 | docker-machine inspect
码头检查
Usage: docker-machine inspect [OPTIONS] [arg...]
Inspect information about a machine
Description:
Argument is a machine name.
Options:
--format, -f Format the output using the given go template.
默认情况下,这将将有关机器的信息呈现为JSON。如果指定了格式,则将对每个结果执行给定的模板。
围棋文本/模板包描述格式的所有细节。
除了text/template
语法之外,还有一些额外的功能,json
并且prettyjson
可以用来将输出格式化为JSON(如下文档所述)。
实例
列出机器的所有细节:
这是默认的使用方式inspect
。
$ docker-machine inspect dev
{
"DriverName": "virtualbox",
"Driver": {
"MachineName": "docker-host-128be8d287b2028316c0ad5714b90bcfc11f998056f2f790f7c1f43f3d1e6eda",
"SSHPort": 55834,
"Memory": 1024,
"DiskSize": 20000,
"Boot2DockerURL": "",
"IPAddress": "192.168.5.99"
},
...
}
获取机器的IP地址:
在大多数情况下,您可以以相当简单的方式从JSON中选择任何字段。
$ docker-machine inspect --format='{{.Driver.IPAddress}}' dev
192.168.5.99
格式化详细信息:
如果希望将信息子集格式化为JSON,则可以使用json
函数在模板中。
$ docker-machine inspect --format='' dev-fusion
{"Boot2DockerURL":"","CPUS":8,"CPUs":8,"CaCertPath":"/Users/hairyhenderson/.docker/machine/certs/ca.pem","DiskSize":20000,"IPAddress":"172.16.62.129","ISO":"/Users/hairyhenderson/.docker/machine/machines/dev-fusion/boot2docker-1.5.0-GH747.iso","MachineName":"dev-fusion","Memory":1024,"PrivateKeyPath":"/Users/hairyhenderson/.docker/machine/certs/ca-key.pem","SSHPort":22,"SSHUser":"docker","SwarmDiscovery":"","SwarmHost":"tcp://0.0.0.0:3376","SwarmMaster":false}
虽然这是可用的,但它并不是很容易读懂。因此,prettyjson
*
$ docker-machine inspect --format='{{prettyjson .Driver}}' dev-fusion
{
"Boot2DockerURL": "",
"CPUS": 8,
"CPUs": 8,
"CaCertPath": "/Users/hairyhenderson/.docker/machine/certs/ca.pem",
"DiskSize": 20000,
"IPAddress": "172.16.62.129",
"ISO": "/Users/hairyhenderson/.docker/machine/machines/dev-fusion/boot2docker-1.5.0-GH747.iso",
"MachineName": "dev-fusion",
"Memory": 1024,
"PrivateKeyPath": "/Users/hairyhenderson/.docker/machine/certs/ca-key.pem",
"SSHPort": 22,
"SSHUser": "docker",
"SwarmDiscovery": "",
"SwarmHost": "tcp://0.0.0.0:3376",
"SwarmMaster": false
}