151 lines
4.6 KiB
YAML
151 lines
4.6 KiB
YAML
|
command: docker stack services
|
||
|
short: List the services in the stack
|
||
|
long: |-
|
||
|
Lists the services that are running as part of the specified stack.
|
||
|
|
||
|
> **Note**
|
||
|
>
|
||
|
> This is a cluster management command, and must be executed on a swarm
|
||
|
> manager node. To learn about managers and workers, refer to the
|
||
|
> [Swarm mode section](https://docs.docker.com/engine/swarm/) in the
|
||
|
> documentation.
|
||
|
usage: docker stack services [OPTIONS] STACK
|
||
|
pname: docker stack
|
||
|
plink: docker_stack.yaml
|
||
|
options:
|
||
|
- option: filter
|
||
|
shorthand: f
|
||
|
value_type: filter
|
||
|
description: Filter output based on conditions provided
|
||
|
deprecated: false
|
||
|
experimental: false
|
||
|
experimentalcli: false
|
||
|
kubernetes: false
|
||
|
swarm: false
|
||
|
- option: format
|
||
|
value_type: string
|
||
|
description: Pretty-print services using a Go template
|
||
|
deprecated: false
|
||
|
experimental: false
|
||
|
experimentalcli: false
|
||
|
kubernetes: false
|
||
|
swarm: false
|
||
|
- option: namespace
|
||
|
value_type: string
|
||
|
description: Kubernetes namespace to use
|
||
|
deprecated: false
|
||
|
experimental: false
|
||
|
experimentalcli: false
|
||
|
kubernetes: true
|
||
|
swarm: false
|
||
|
- option: quiet
|
||
|
shorthand: q
|
||
|
value_type: bool
|
||
|
default_value: "false"
|
||
|
description: Only display IDs
|
||
|
deprecated: false
|
||
|
experimental: false
|
||
|
experimentalcli: false
|
||
|
kubernetes: false
|
||
|
swarm: false
|
||
|
inherited_options:
|
||
|
- option: kubeconfig
|
||
|
value_type: string
|
||
|
description: Kubernetes config file
|
||
|
deprecated: false
|
||
|
experimental: false
|
||
|
experimentalcli: false
|
||
|
kubernetes: true
|
||
|
swarm: false
|
||
|
- option: orchestrator
|
||
|
value_type: string
|
||
|
description: Orchestrator to use (swarm|kubernetes|all)
|
||
|
deprecated: false
|
||
|
experimental: false
|
||
|
experimentalcli: false
|
||
|
kubernetes: false
|
||
|
swarm: false
|
||
|
examples: |-
|
||
|
The following command shows all services in the `myapp` stack:
|
||
|
|
||
|
```bash
|
||
|
$ docker stack services myapp
|
||
|
|
||
|
ID NAME REPLICAS IMAGE COMMAND
|
||
|
7be5ei6sqeye myapp_web 1/1 nginx@sha256:23f809e7fd5952e7d5be065b4d3643fbbceccd349d537b62a123ef2201bc886f
|
||
|
dn7m7nhhfb9y myapp_db 1/1 mysql@sha256:a9a5b559f8821fe73d58c3606c812d1c044868d42c63817fa5125fd9d8b7b539
|
||
|
```
|
||
|
|
||
|
### Filtering
|
||
|
|
||
|
The filtering flag (`-f` or `--filter`) format is a `key=value` pair. If there
|
||
|
is more than one filter, then pass multiple flags (e.g. `--filter "foo=bar" --filter "bif=baz"`).
|
||
|
Multiple filter flags are combined as an `OR` filter.
|
||
|
|
||
|
The following command shows both the `web` and `db` services:
|
||
|
|
||
|
```bash
|
||
|
$ docker stack services --filter name=myapp_web --filter name=myapp_db myapp
|
||
|
|
||
|
ID NAME REPLICAS IMAGE COMMAND
|
||
|
7be5ei6sqeye myapp_web 1/1 nginx@sha256:23f809e7fd5952e7d5be065b4d3643fbbceccd349d537b62a123ef2201bc886f
|
||
|
dn7m7nhhfb9y myapp_db 1/1 mysql@sha256:a9a5b559f8821fe73d58c3606c812d1c044868d42c63817fa5125fd9d8b7b539
|
||
|
```
|
||
|
|
||
|
The currently supported filters are:
|
||
|
|
||
|
* id / ID (`--filter id=7be5ei6sqeye`, or `--filter ID=7be5ei6sqeye`)
|
||
|
* Swarm: supported
|
||
|
* Kubernetes: not supported
|
||
|
* label (`--filter label=key=value`)
|
||
|
* Swarm: supported
|
||
|
* Kubernetes: supported
|
||
|
* mode (`--filter mode=replicated`, or `--filter mode=global`)
|
||
|
* Swarm: not supported
|
||
|
* Kubernetes: supported
|
||
|
* name (`--filter name=myapp_web`)
|
||
|
* Swarm: supported
|
||
|
* Kubernetes: supported
|
||
|
* node (`--filter node=mynode`)
|
||
|
* Swarm: not supported
|
||
|
* Kubernetes: supported
|
||
|
* service (`--filter service=web`)
|
||
|
* Swarm: not supported
|
||
|
* Kubernetes: supported
|
||
|
|
||
|
### Formatting
|
||
|
|
||
|
The formatting options (`--format`) pretty-prints services output
|
||
|
using a Go template.
|
||
|
|
||
|
Valid placeholders for the Go template are listed below:
|
||
|
|
||
|
Placeholder | Description
|
||
|
------------|-------------------------------------------------------------------
|
||
|
`.ID` | Service ID
|
||
|
`.Name` | Service name
|
||
|
`.Mode` | Service mode (replicated, global)
|
||
|
`.Replicas` | Service replicas
|
||
|
`.Image` | Service image
|
||
|
|
||
|
When using the `--format` option, the `stack services` command will either
|
||
|
output 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
|
||
|
`ID`, `Mode`, and `Replicas` entries separated by a colon (`:`) for all services:
|
||
|
|
||
|
```bash
|
||
|
$ docker stack services --format "{{.ID}}: {{.Mode}} {{.Replicas}}"
|
||
|
|
||
|
0zmvwuiu3vue: replicated 10/10
|
||
|
fm6uf97exkul: global 5/5
|
||
|
```
|
||
|
deprecated: false
|
||
|
min_api_version: "1.25"
|
||
|
experimental: false
|
||
|
experimentalcli: false
|
||
|
kubernetes: false
|
||
|
swarm: false
|
||
|
|