github.com/pwn-term/docker@v0.0.0-20210616085119-6e977cce2565/cli/docs/reference/commandline/stack_services.md (about)

     1  ---
     2  title: "stack services"
     3  description: "The stack services command description and usage"
     4  keywords: "stack, services"
     5  ---
     6  
     7  # stack services
     8  
     9  ```markdown
    10  Usage:  docker stack services [OPTIONS] STACK
    11  
    12  List the services in the stack
    13  
    14  Options:
    15    -f, --filter filter         Filter output based on conditions provided
    16        --format string         Pretty-print services using a Go template
    17        --help                  Print usage
    18        --kubeconfig string     Kubernetes config file
    19        --namespace string      Kubernetes namespace to use
    20        --orchestrator string   Orchestrator to use (swarm|kubernetes|all)
    21    -q, --quiet                 Only display IDs
    22  ```
    23  
    24  ## Description
    25  
    26  Lists the services that are running as part of the specified stack.
    27  
    28  > **Note**
    29  >
    30  > This is a cluster management command, and must be executed on a swarm
    31  > manager node. To learn about managers and workers, refer to the
    32  > [Swarm mode section](https://docs.docker.com/engine/swarm/) in the
    33  > documentation.
    34  
    35  ## Examples
    36  
    37  The following command shows all services in the `myapp` stack:
    38  
    39  ```bash
    40  $ docker stack services myapp
    41  
    42  ID            NAME            REPLICAS  IMAGE                                                                          COMMAND
    43  7be5ei6sqeye  myapp_web       1/1       nginx@sha256:23f809e7fd5952e7d5be065b4d3643fbbceccd349d537b62a123ef2201bc886f
    44  dn7m7nhhfb9y  myapp_db        1/1       mysql@sha256:a9a5b559f8821fe73d58c3606c812d1c044868d42c63817fa5125fd9d8b7b539
    45  ```
    46  
    47  ### Filtering
    48  
    49  The filtering flag (`-f` or `--filter`) format is a `key=value` pair. If there
    50  is more than one filter, then pass multiple flags (e.g. `--filter "foo=bar" --filter "bif=baz"`).
    51  Multiple filter flags are combined as an `OR` filter.
    52  
    53  The following command shows both the `web` and `db` services:
    54  
    55  ```bash
    56  $ docker stack services --filter name=myapp_web --filter name=myapp_db myapp
    57  
    58  ID            NAME            REPLICAS  IMAGE                                                                          COMMAND
    59  7be5ei6sqeye  myapp_web       1/1       nginx@sha256:23f809e7fd5952e7d5be065b4d3643fbbceccd349d537b62a123ef2201bc886f
    60  dn7m7nhhfb9y  myapp_db        1/1       mysql@sha256:a9a5b559f8821fe73d58c3606c812d1c044868d42c63817fa5125fd9d8b7b539
    61  ```
    62  
    63  The currently supported filters are:
    64  
    65  * id / ID (`--filter id=7be5ei6sqeye`, or `--filter ID=7be5ei6sqeye`)
    66    * Swarm: supported
    67    * Kubernetes: not supported
    68  * label (`--filter label=key=value`)
    69    * Swarm: supported
    70    * Kubernetes: supported
    71  * mode (`--filter mode=replicated`, or `--filter mode=global`)
    72    * Swarm: not supported
    73    * Kubernetes: supported
    74  * name (`--filter name=myapp_web`)
    75    * Swarm: supported
    76    * Kubernetes: supported
    77  * node (`--filter node=mynode`)
    78    * Swarm: not supported
    79    * Kubernetes: supported
    80  * service (`--filter service=web`)
    81    * Swarm: not supported
    82    * Kubernetes: supported
    83  
    84  ### Formatting
    85  
    86  The formatting options (`--format`) pretty-prints services output
    87  using a Go template.
    88  
    89  Valid placeholders for the Go template are listed below:
    90  
    91  Placeholder | Description
    92  ------------|-------------------------------------------------------------------
    93  `.ID`       | Service ID
    94  `.Name`     | Service name
    95  `.Mode`     | Service mode (replicated, global)
    96  `.Replicas` | Service replicas
    97  `.Image`    | Service image
    98  
    99  When using the `--format` option, the `stack services` command will either
   100  output the data exactly as the template declares or, when using the
   101  `table` directive, includes column headers as well.
   102  
   103  The following example uses a template without headers and outputs the
   104  `ID`, `Mode`, and `Replicas` entries separated by a colon (`:`) for all services:
   105  
   106  ```bash
   107  $ docker stack services --format "{{.ID}}: {{.Mode}} {{.Replicas}}"
   108  
   109  0zmvwuiu3vue: replicated 10/10
   110  fm6uf97exkul: global 5/5
   111  ```
   112  
   113  
   114  ## Related commands
   115  
   116  * [stack deploy](stack_deploy.md)
   117  * [stack ls](stack_ls.md)
   118  * [stack ps](stack_ps.md)
   119  * [stack rm](stack_rm.md)