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