github.com/pwn-term/docker@v0.0.0-20210616085119-6e977cce2565/cli/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  # service ls
     8  
     9  ```Markdown
    10  Usage:  docker service ls [OPTIONS]
    11  
    12  List services
    13  
    14  Aliases:
    15    ls, list
    16  
    17  Options:
    18    -f, --filter filter   Filter output based on conditions provided
    19        --format string   Pretty-print services using a Go template
    20        --help            Print usage
    21    -q, --quiet           Only display IDs
    22  ```
    23  
    24  ## Description
    25  
    26  This command lists services are running in the swarm.
    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  On a manager node:
    38  
    39  ```bash
    40  $ docker service ls
    41  
    42  ID            NAME      MODE            REPLICAS             IMAGE
    43  c8wgl7q4ndfd  frontend  replicated      5/5                  nginx:alpine
    44  dmu1ept4cxcf  redis     replicated      3/3                  redis:3.0.6
    45  iwe3278osahj  mongo     global          7/7                  mongo:3.3
    46  hh08h9uu8uwr  job       replicated-job  1/1 (3/5 completed)  nginx:latest        
    47  ```
    48  
    49  The `REPLICAS` column shows both the *actual* and *desired* number of tasks for
    50  the service. If the service is in `replicated-job` or `global-job`, it will
    51  additionally show the completion status of the job as completed tasks over
    52  total tasks the job will execute.
    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  * [mode](service_ls.md#mode)
    64  * [name](service_ls.md#name)
    65  
    66  #### id
    67  
    68  The `id` filter matches all or part of a service's id.
    69  
    70  ```bash
    71  $ docker service ls -f "id=0bcjw"
    72  ID            NAME   MODE        REPLICAS  IMAGE
    73  0bcjwfh8ychr  redis  replicated  1/1       redis:3.0.6
    74  ```
    75  
    76  #### label
    77  
    78  The `label` filter matches services based on the presence of a `label` alone or
    79  a `label` and a value.
    80  
    81  The following filter matches all services with a `project` label regardless of
    82  its value:
    83  
    84  ```bash
    85  $ docker service ls --filter label=project
    86  ID            NAME       MODE        REPLICAS  IMAGE
    87  01sl1rp6nj5u  frontend2  replicated  1/1       nginx:alpine
    88  36xvvwwauej0  frontend   replicated  5/5       nginx:alpine
    89  74nzcxxjv6fq  backend    replicated  3/3       redis:3.0.6
    90  ```
    91  
    92  The following filter matches only services with the `project` label with the
    93  `project-a` value.
    94  
    95  ```bash
    96  $ docker service ls --filter label=project=project-a
    97  ID            NAME      MODE        REPLICAS  IMAGE
    98  36xvvwwauej0  frontend  replicated  5/5       nginx:alpine
    99  74nzcxxjv6fq  backend   replicated  3/3       redis:3.0.6
   100  ```
   101  
   102  #### mode
   103  
   104  The `mode` filter matches on the mode (either `replicated` or `global`) of a service.
   105  
   106  The following filter matches only `global` services.
   107  
   108  ```bash
   109  $ docker service ls --filter mode=global
   110  ID                  NAME                MODE                REPLICAS            IMAGE
   111  w7y0v2yrn620        top                 global              1/1                 busybox
   112  ```
   113  
   114  #### name
   115  
   116  The `name` filter matches on all or part of a service's name.
   117  
   118  The following filter matches services with a name containing `redis`.
   119  
   120  ```bash
   121  $ docker service ls --filter name=redis
   122  ID            NAME   MODE        REPLICAS  IMAGE
   123  0bcjwfh8ychr  redis  replicated  1/1       redis:3.0.6
   124  ```
   125  
   126  ### Formatting
   127  
   128  The formatting options (`--format`) pretty-prints services output
   129  using a Go template.
   130  
   131  Valid placeholders for the Go template are listed below:
   132  
   133  Placeholder | Description
   134  ------------|------------------------------------------------------------------------------------------
   135  `.ID`       | Service ID
   136  `.Name`     | Service name
   137  `.Mode`     | Service mode (replicated, global)
   138  `.Replicas` | Service replicas
   139  `.Image`    | Service image
   140  `.Ports`    | Service ports published in ingress mode
   141  
   142  When using the `--format` option, the `service ls` command will either
   143  output the data exactly as the template declares or, when using the
   144  `table` directive, includes column headers as well.
   145  
   146  The following example uses a template without headers and outputs the
   147  `ID`, `Mode`, and `Replicas` entries separated by a colon (`:`) for all services:
   148  
   149  ```bash
   150  $ docker service ls --format "{{.ID}}: {{.Mode}} {{.Replicas}}"
   151  
   152  0zmvwuiu3vue: replicated 10/10
   153  fm6uf97exkul: global 5/5
   154  ```
   155  
   156  ## Related commands
   157  
   158  * [service create](service_create.md)
   159  * [service inspect](service_inspect.md)
   160  * [service logs](service_logs.md)
   161  * [service ps](service_ps.md)
   162  * [service rm](service_rm.md)
   163  * [service rollback](service_rollback.md)
   164  * [service scale](service_scale.md)
   165  * [service update](service_update.md)