...

Text file src/github.com/docker/cli/docs/reference/commandline/stack_ls.md

Documentation: github.com/docker/cli/docs/reference/commandline

     1# stack ls
     2
     3<!---MARKER_GEN_START-->
     4List stacks
     5
     6### Aliases
     7
     8`docker stack ls`, `docker stack list`
     9
    10### Options
    11
    12| Name                  | Type     | Default | Description                                                                                                                                                                                                                                                                                                                                                                                                                          |
    13|:----------------------|:---------|:--------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
    14| [`--format`](#format) | `string` |         | Format output using a custom template:<br>'table':            Print output in table format with column headers (default)<br>'table TEMPLATE':   Print output in table format using the given Go template<br>'json':             Print in JSON format<br>'TEMPLATE':         Print output using the given Go template.<br>Refer to https://docs.docker.com/go/formatting/ for more information about formatting output with templates |
    15
    16
    17<!---MARKER_GEN_END-->
    18
    19## Description
    20
    21Lists the stacks.
    22
    23> **Note**
    24>
    25> This is a cluster management command, and must be executed on a swarm
    26> manager node. To learn about managers and workers, refer to the
    27> [Swarm mode section](https://docs.docker.com/engine/swarm/) in the
    28> documentation.
    29
    30## Examples
    31
    32The following command shows all stacks and some additional information:
    33
    34```console
    35$ docker stack ls
    36
    37ID                 SERVICES            ORCHESTRATOR
    38myapp              2                   Kubernetes
    39vossibility-stack  6                   Swarm
    40```
    41
    42### <a name="format"></a> Format the output (--format)
    43
    44The formatting option (`--format`) pretty-prints stacks using a Go template.
    45
    46Valid placeholders for the Go template are listed below:
    47
    48| Placeholder     | Description        |
    49|-----------------|--------------------|
    50| `.Name`         | Stack name         |
    51| `.Services`     | Number of services |
    52| `.Orchestrator` | Orchestrator name  |
    53| `.Namespace`    | Namespace          |
    54
    55When using the `--format` option, the `stack ls` command either outputs
    56the data exactly as the template declares or, when using the
    57`table` directive, includes column headers as well.
    58
    59The following example uses a template without headers and outputs the
    60`Name` and `Services` entries separated by a colon (`:`) for all stacks:
    61
    62```console
    63$ docker stack ls --format "{{.Name}}: {{.Services}}"
    64web-server: 1
    65web-cache: 4
    66```
    67
    68To list all stacks in JSON format, use the `json` directive:
    69
    70```console
    71$ docker stack ls --format json
    72{"Name":"myapp","Namespace":"","Orchestrator":"Swarm","Services":"3"}
    73```
    74
    75## Related commands
    76
    77* [stack deploy](stack_deploy.md)
    78* [stack ps](stack_ps.md)
    79* [stack rm](stack_rm.md)
    80* [stack services](stack_services.md)

View as plain text