Files
docker-docs/machine/reference/ls.md
Akim Demaille 14b53b68c3 Jekyll: don't put {% raw %} directives in pre blocks
Replace all occurrences of

    ```foo
    {% raw %}
    bar
    {% endraw %}
    ```

(which generates spurious empty lines in the rendered pre block) with

    {% raw %}
    ```foo
    bar
    ```
    {% endraw %}

Also, fix some occurrences where the raw section is too large and
prevented interpretation of Jekyll directives.

This is the syntax used in the documentation of Jekyll itself:

https://raw.githubusercontent.com/jekyll/jekyll/master/docs/_docs/templates.md

FTR, done with two perl substitutions:

    '^([\t ]*```[^\n]*
    )([ \t]*\{% raw %\}[^\n]*
    )' '$2$1'

and

    '^([ \t]*\{% endraw %\}[^\n]*
    )([\t ]*```[^\n]*
    )' '$2$1'

and manually tweaks.  A mechanical check would be most useful.

Signed-off-by: Akim Demaille <akim.demaille@docker.com>
2018-03-13 10:28:29 -07:00

118 lines
4.4 KiB
Markdown

---
description: List machines
keywords: machine, ls, subcommand
title: docker-machine ls
---
```none
Usage: docker-machine ls [OPTIONS] [arg...]
List machines
Options:
--quiet, -q Enable quiet mode
--filter [--filter option --filter option] Filter output based on conditions provided
--timeout, -t "10" Timeout in seconds, default to 10s
--format, -f Pretty-print machines using a Go template
```
## Timeout
The `ls` command tries to reach each host in parallel. If a given host does not
answer in less than 10 seconds, the `ls` command states that this host is in
`Timeout` state. In some circumstances (poor connection, high load, or while
troubleshooting), you may want to increase or decrease this value. You can use
the -t flag for this purpose with a numerical value in seconds.
### Example
```none
$ docker-machine ls -t 12
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
default - virtualbox Running tcp://192.168.99.100:2376 v1.9.1
```
## Filtering
The filtering flag (`--filter`) format is a `key=value` pair. If there is more
than one filter, then pass multiple flags. For example:
`--filter "foo=bar" --filter "bif=baz"`
The currently supported filters are:
- driver (driver name)
- swarm (swarm master's name)
- state (`Running|Paused|Saved|Stopped|Stopping|Starting|Error`)
- name (Machine name returned by driver, supports [golang style](https://github.com/google/re2/wiki/Syntax) regular expressions)
- label (Machine created with `--engine-label` option, can be filtered with `label=<key>[=<value>]`)
### Examples
```none
$ docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
dev - virtualbox Stopped
foo0 - virtualbox Running tcp://192.168.99.105:2376 v1.9.1
foo1 - virtualbox Running tcp://192.168.99.106:2376 v1.9.1
foo2 * virtualbox Running tcp://192.168.99.107:2376 v1.9.1
$ docker-machine ls --filter name=foo0
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
foo0 - virtualbox Running tcp://192.168.99.105:2376 v1.9.1
$ docker-machine ls --filter driver=virtualbox --filter state=Stopped
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
dev - virtualbox Stopped v1.9.1
$ docker-machine ls --filter label=com.class.app=foo1 --filter label=com.class.app=foo2
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
foo1 - virtualbox Running tcp://192.168.99.105:2376 v1.9.1
foo2 * virtualbox Running tcp://192.168.99.107:2376 v1.9.1
```
## Formatting
The formatting option (`--format`) pretty-prints machines using a Go template.
Valid placeholders for the Go template are listed below:
| Placeholder | Description |
|:---------------|:-----------------------------------------|
| .Name | Machine name |
| .Active | Is the machine active? |
| .ActiveHost | Is the machine an active non-swarm host? |
| .ActiveSwarm | Is the machine an active swarm master? |
| .DriverName | Driver name |
| .State | Machine state (running, stopped...) |
| .URL | Machine URL |
| .Swarm | Machine swarm name |
| .Error | Machine errors |
| .DockerVersion | Docker Daemon version |
| .ResponseTime | Time taken by the host to respond |
When using the `--format` option, the `ls` command either outputs the data exactly as the template declares or,
when using the table directive, includes column headers as well.
The following example uses a template without headers and outputs the `Name` and `Driver` entries separated by a colon
for all running machines:
{% raw %}
```none
$ docker-machine ls --format "{{.Name}}: {{.DriverName}}"
default: virtualbox
ec2: amazonec2
```
{% endraw %}
To list all machine names with their driver in a table format you can use:
{% raw %}
```none
$ docker-machine ls --format "table {{.Name}} {{.DriverName}}"
NAME DRIVER
default virtualbox
ec2 amazonec2
```
{% endraw %}