码头工人机器检查

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。如果指定了格式,则为每个结果执行给定的模板。

Go的文本/模板包描述了格式的所有细节。

除了text/template语法外,还有一些其他函数 jsonprettyjson,可用于将输出格式化为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
}

机器检查子命令