github.com/khulnasoft/cli@v0.0.0-20240402070845-01bcad7beefa/docs/reference/commandline/stack_ls.md (about)

     1  # stack ls
     2  
     3  <!---MARKER_GEN_START-->
     4  List 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  
    21  Lists 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  
    32  The following command shows all stacks and some additional information:
    33  
    34  ```console
    35  $ docker stack ls
    36  
    37  ID                 SERVICES            ORCHESTRATOR
    38  myapp              2                   Kubernetes
    39  vossibility-stack  6                   Swarm
    40  ```
    41  
    42  ### <a name="format"></a> Format the output (--format)
    43  
    44  The formatting option (`--format`) pretty-prints stacks using a Go template.
    45  
    46  Valid 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  
    55  When using the `--format` option, the `stack ls` command either outputs
    56  the data exactly as the template declares or, when using the
    57  `table` directive, includes column headers as well.
    58  
    59  The 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}}"
    64  web-server: 1
    65  web-cache: 4
    66  ```
    67  
    68  To 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)