github.com/yogeshlonkar/moby@v1.13.2-0.20201203103638-c0b64beaea94/docs/reference/commandline/service_ps.md (about)

     1  ---
     2  title: "service ps"
     3  description: "The service ps command description and usage"
     4  keywords: "service, tasks, ps"
     5  aliases: ["/engine/reference/commandline/service_tasks/"]
     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  # service ps
    18  
    19  ```Markdown
    20  Usage:  docker service ps [OPTIONS] SERVICE
    21  
    22  List the tasks of a service
    23  
    24  Options:
    25    -f, --filter filter   Filter output based on conditions provided
    26        --help            Print usage
    27        --no-resolve      Do not map IDs to Names
    28        --no-trunc        Do not truncate output
    29    -q, --quiet           Only display task IDs
    30  ```
    31  
    32  ## Description
    33  
    34  Lists the tasks that are running as part of the specified services. This command
    35  has to be run targeting a manager node.
    36  
    37  ## Examples
    38  
    39  ### List the tasks that are part of a service
    40  
    41  The following command shows all the tasks that are part of the `redis` service:
    42  
    43  ```bash
    44  $ docker service ps redis
    45  
    46  ID             NAME      IMAGE        NODE      DESIRED STATE  CURRENT STATE          ERROR  PORTS
    47  0qihejybwf1x   redis.1   redis:3.0.5  manager1  Running        Running 8 seconds
    48  bk658fpbex0d   redis.2   redis:3.0.5  worker2   Running        Running 9 seconds
    49  5ls5s5fldaqg   redis.3   redis:3.0.5  worker1   Running        Running 9 seconds
    50  8ryt076polmc   redis.4   redis:3.0.5  worker1   Running        Running 9 seconds
    51  1x0v8yomsncd   redis.5   redis:3.0.5  manager1  Running        Running 8 seconds
    52  71v7je3el7rr   redis.6   redis:3.0.5  worker2   Running        Running 9 seconds
    53  4l3zm9b7tfr7   redis.7   redis:3.0.5  worker2   Running        Running 9 seconds
    54  9tfpyixiy2i7   redis.8   redis:3.0.5  worker1   Running        Running 9 seconds
    55  3w1wu13yupln   redis.9   redis:3.0.5  manager1  Running        Running 8 seconds
    56  8eaxrb2fqpbn   redis.10  redis:3.0.5  manager1  Running        Running 8 seconds
    57  ```
    58  
    59  In addition to _running_ tasks, the output also shows the task history. For
    60  example, after updating the service to use the `redis:3.0.6` image, the output
    61  may look like this:
    62  
    63  ```bash
    64  $ docker service ps redis
    65  
    66  ID            NAME         IMAGE        NODE      DESIRED STATE  CURRENT STATE                   ERROR  PORTS
    67  50qe8lfnxaxk  redis.1      redis:3.0.6  manager1  Running        Running 6 seconds ago
    68  ky2re9oz86r9   \_ redis.1  redis:3.0.5  manager1  Shutdown       Shutdown 8 seconds ago
    69  3s46te2nzl4i  redis.2      redis:3.0.6  worker2   Running        Running less than a second ago
    70  nvjljf7rmor4   \_ redis.2  redis:3.0.6  worker2   Shutdown       Rejected 23 seconds ago        "No such image: redis@sha256:6…"
    71  vtiuz2fpc0yb   \_ redis.2  redis:3.0.5  worker2   Shutdown       Shutdown 1 second ago
    72  jnarweeha8x4  redis.3      redis:3.0.6  worker1   Running        Running 3 seconds ago
    73  vs448yca2nz4   \_ redis.3  redis:3.0.5  worker1   Shutdown       Shutdown 4 seconds ago
    74  jf1i992619ir  redis.4      redis:3.0.6  worker1   Running        Running 10 seconds ago
    75  blkttv7zs8ee   \_ redis.4  redis:3.0.5  worker1   Shutdown       Shutdown 11 seconds ago
    76  ```
    77  
    78  The number of items in the task history is determined by the
    79  `--task-history-limit` option that was set when initializing the swarm. You can
    80  change the task history retention limit using the
    81  [`docker swarm update`](swarm_update.md) command.
    82  
    83  When deploying a service, docker resolves the digest for the service's
    84  image, and pins the service to that digest. The digest is not shown by
    85  default, but is printed if `--no-trunc` is used. The `--no-trunc` option
    86  also shows the non-truncated task ID, and error-messages, as can be seen below;
    87  
    88  ```bash
    89  $ docker service ps --no-trunc redis
    90  
    91  ID                          NAME         IMAGE                                                                                NODE      DESIRED STATE  CURRENT STATE            ERROR                                                                                           PORTS
    92  50qe8lfnxaxksi9w2a704wkp7   redis.1      redis:3.0.6@sha256:6a692a76c2081888b589e26e6ec835743119fe453d67ecf03df7de5b73d69842  manager1  Running        Running 5 minutes ago
    93  ky2re9oz86r9556i2szb8a8af   \_ redis.1   redis:3.0.5@sha256:f8829e00d95672c48c60f468329d6693c4bdd28d1f057e755f8ba8b40008682e  worker2   Shutdown       Shutdown 5 minutes ago
    94  bk658fpbex0d57cqcwoe3jthu   redis.2      redis:3.0.6@sha256:6a692a76c2081888b589e26e6ec835743119fe453d67ecf03df7de5b73d69842  worker2   Running        Running 5 seconds
    95  nvjljf7rmor4htv7l8rwcx7i7   \_ redis.2   redis:3.0.6@sha256:6a692a76c2081888b589e26e6ec835743119fe453d67ecf03df7de5b73d69842  worker2   Shutdown       Rejected 5 minutes ago   "No such image: redis@sha256:6a692a76c2081888b589e26e6ec835743119fe453d67ecf03df7de5b73d69842"
    96  ```
    97  
    98  ### Filtering
    99  
   100  The filtering flag (`-f` or `--filter`) format is a `key=value` pair. If there
   101  is more than one filter, then pass multiple flags (e.g. `--filter "foo=bar" --filter "bif=baz"`).
   102  Multiple filter flags are combined as an `OR` filter. For example,
   103  `-f name=redis.1 -f name=redis.7` returns both `redis.1` and `redis.7` tasks.
   104  
   105  The currently supported filters are:
   106  
   107  * [id](#id)
   108  * [name](#name)
   109  * [node](#node)
   110  * [desired-state](#desired-state)
   111  
   112  
   113  #### id
   114  
   115  The `id` filter matches on all or a prefix of a task's ID.
   116  
   117  ```bash
   118  $ docker service ps -f "id=8" redis
   119  
   120  ID             NAME      IMAGE        NODE      DESIRED STATE  CURRENT STATE      ERROR  PORTS
   121  8ryt076polmc   redis.4   redis:3.0.6  worker1   Running        Running 9 seconds
   122  8eaxrb2fqpbn   redis.10  redis:3.0.6  manager1  Running        Running 8 seconds
   123  ```
   124  
   125  #### name
   126  
   127  The `name` filter matches on task names.
   128  
   129  ```bash
   130  $ docker service ps -f "name=redis.1" redis
   131  ID            NAME     IMAGE        NODE      DESIRED STATE  CURRENT STATE      ERROR  PORTS
   132  qihejybwf1x5  redis.1  redis:3.0.6  manager1  Running        Running 8 seconds
   133  ```
   134  
   135  
   136  #### node
   137  
   138  The `node` filter matches on a node name or a node ID.
   139  
   140  ```bash
   141  $ docker service ps -f "node=manager1" redis
   142  ID            NAME      IMAGE        NODE      DESIRED STATE  CURRENT STATE      ERROR  PORTS
   143  0qihejybwf1x  redis.1   redis:3.0.6  manager1  Running        Running 8 seconds
   144  1x0v8yomsncd  redis.5   redis:3.0.6  manager1  Running        Running 8 seconds
   145  3w1wu13yupln  redis.9   redis:3.0.6  manager1  Running        Running 8 seconds
   146  8eaxrb2fqpbn  redis.10  redis:3.0.6  manager1  Running        Running 8 seconds
   147  ```
   148  
   149  
   150  #### desired-state
   151  
   152  The `desired-state` filter can take the values `running`, `shutdown`, and `accepted`.
   153  
   154  
   155  ## Related commands
   156  
   157  * [service create](service_create.md)
   158  * [service inspect](service_inspect.md)
   159  * [service logs](service_logs.md)
   160  * [service ls](service_ls.md)
   161  * [service rm](service_rm.md)
   162  * [service scale](service_scale.md)
   163  * [service update](service_update.md)