Adding docs for the inspect command

Signed-off-by: Dave Henderson <Dave.Henderson@ca.ibm.com>
This commit is contained in:
Dave Henderson 2015-04-30 23:03:37 -04:00
parent 7dcd4c2dfd
commit 2e85fd32e4
1 changed files with 74 additions and 3 deletions

View File

@ -592,7 +592,32 @@ $ # The environment variables have been unset.
#### inspect #### inspect
Inspect information about a machine. ```
Usage: docker-machine inspect [OPTIONS] [arg...]
Inspect information about a machine
Description:
Argument is a machine name. Will use the active machine if none is provided.
Options:
--format, -f Format the output using the given go template.
```
By default, this will render all results in a JSON array. If a format is
specified, the given template will be executed for each result.
Go's [text/template](http://golang.org/pkg/text/template/) package
describes all the details of the format.
In addition to the `text/template` syntax, there are some additional functions,
`json` and `prettyjson`, which can be used to format the output as JSON (documented below).
##### Examples
**List all the details of a machine:**
This is the default usage of `inspect`.
``` ```
$ docker-machine inspect dev $ docker-machine inspect dev
@ -603,8 +628,54 @@ $ docker-machine inspect dev
"SSHPort": 55834, "SSHPort": 55834,
"Memory": 1024, "Memory": 1024,
"DiskSize": 20000, "DiskSize": 20000,
"Boot2DockerURL": "" "Boot2DockerURL": "",
"IPAddress": "192.168.5.99"
},
...
} }
```
**Get a machine's IP address:**
For the most part, you can pick out any field from the JSON in a fairly
straightforward manner.
```
$ docker-machine inspect --format='{{.Driver.IPAddress}}' dev
192.168.5.99
```
**Formatting details:**
If you want a subset of information formatted as JSON, you can use the `json`
function in the template.
```
$ docker-machine inspect --format='{{json .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}
```
While this is usable, it's not very human-readable. For this reason, there is
`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
} }
``` ```