github.com/fabiokung/docker@v0.11.2-0.20170222101415-4534dcd49497/docs/reference/commandline/service_ls.md (about) 1 --- 2 title: "service ls" 3 description: "The service ls command description and usage" 4 keywords: "service, ls" 5 --- 6 7 <!-- This file is maintained within the docker/docker Github 8 repository at https://github.com/docker/docker/. 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 # service ls 17 18 ```Markdown 19 Usage: docker service ls [OPTIONS] 20 21 List services 22 23 Aliases: 24 ls, list 25 26 Options: 27 -f, --filter filter Filter output based on conditions provided 28 --format string Pretty-print services using a Go template 29 --help Print usage 30 -q, --quiet Only display IDs 31 ``` 32 33 ## Description 34 35 This command when run targeting a manager, lists services are running in the 36 swarm. 37 38 ## Examples 39 40 On a manager node: 41 42 ```bash 43 $ docker service ls 44 45 ID NAME MODE REPLICAS IMAGE 46 c8wgl7q4ndfd frontend replicated 5/5 nginx:alpine 47 dmu1ept4cxcf redis replicated 3/3 redis:3.0.6 48 iwe3278osahj mongo global 7/7 mongo:3.3 49 ``` 50 51 The `REPLICAS` column shows both the *actual* and *desired* number of tasks for 52 the service. 53 54 ### Filtering 55 56 The filtering flag (`-f` or `--filter`) format is of "key=value". If there is more 57 than one filter, then pass multiple flags (e.g., `--filter "foo=bar" --filter "bif=baz"`) 58 59 The currently supported filters are: 60 61 * [id](service_ls.md#id) 62 * [label](service_ls.md#label) 63 * [name](service_ls.md#name) 64 65 #### id 66 67 The `id` filter matches all or part of a service's id. 68 69 ```bash 70 $ docker service ls -f "id=0bcjw" 71 ID NAME MODE REPLICAS IMAGE 72 0bcjwfh8ychr redis replicated 1/1 redis:3.0.6 73 ``` 74 75 #### label 76 77 The `label` filter matches services based on the presence of a `label` alone or 78 a `label` and a value. 79 80 The following filter matches all services with a `project` label regardless of 81 its value: 82 83 ```bash 84 $ docker service ls --filter label=project 85 ID NAME MODE REPLICAS IMAGE 86 01sl1rp6nj5u frontend2 replicated 1/1 nginx:alpine 87 36xvvwwauej0 frontend replicated 5/5 nginx:alpine 88 74nzcxxjv6fq backend replicated 3/3 redis:3.0.6 89 ``` 90 91 The following filter matches only services with the `project` label with the 92 `project-a` value. 93 94 ```bash 95 $ docker service ls --filter label=project=project-a 96 ID NAME MODE REPLICAS IMAGE 97 36xvvwwauej0 frontend replicated 5/5 nginx:alpine 98 74nzcxxjv6fq backend replicated 3/3 redis:3.0.6 99 ``` 100 101 #### name 102 103 The `name` filter matches on all or part of a service's name. 104 105 The following filter matches services with a name containing `redis`. 106 107 ```bash 108 $ docker service ls --filter name=redis 109 ID NAME MODE REPLICAS IMAGE 110 0bcjwfh8ychr redis replicated 1/1 redis:3.0.6 111 ``` 112 113 ### Formatting 114 115 The formatting options (`--format`) pretty-prints services output 116 using a Go template. 117 118 Valid placeholders for the Go template are listed below: 119 120 Placeholder | Description 121 ------------|------------------------------------------------------------------------------------------ 122 `.ID` | Service ID 123 `.Name` | Service name 124 `.Mode` | Service mode (replicated, global) 125 `.Replicas` | Service replicas 126 `.Image` | Service image 127 128 When using the `--format` option, the `service ls` command will either 129 output the data exactly as the template declares or, when using the 130 `table` directive, includes column headers as well. 131 132 The following example uses a template without headers and outputs the 133 `ID`, `Mode`, and `Replicas` entries separated by a colon for all services: 134 135 ```bash 136 {% raw %} 137 $ docker service ls --format "{{.ID}}: {{.Mode}} {{.Replicas}}" 138 139 0zmvwuiu3vue: replicated 10/10 140 fm6uf97exkul: global 5/5 141 {% endraw %} 142 ``` 143 144 ## Related commands 145 146 * [service create](service_create.md) 147 * [service inspect](service_inspect.md) 148 * [service logs](service_logs.md) 149 * [service rm](service_rm.md) 150 * [service scale](service_scale.md) 151 * [service ps](service_ps.md) 152 * [service update](service_update.md)