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