github.com/zhuohuang-hust/src-cbuild@v0.0.0-20230105071821-c7aab3e7c840/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  Lists the tasks that are running as part of the specified service. This command
    33  has to be run targeting a manager node.
    34  
    35  ## Examples
    36  
    37  ### Listing the tasks that are part of a service
    38  
    39  The following command shows all the tasks that are part of the `redis` service:
    40  
    41  ```bash
    42  $ docker service ps redis
    43  NAME                                IMAGE        NODE      DESIRED STATE  CURRENT STATE
    44  redis.1.0qihejybwf1x5vqi8lgzlgnpq   redis:3.0.6  manager1  Running        Running 8 seconds
    45  redis.2.bk658fpbex0d57cqcwoe3jthu   redis:3.0.6  worker2   Running        Running 9 seconds
    46  redis.3.5ls5s5fldaqg37s9pwayjecrf   redis:3.0.6  worker1   Running        Running 9 seconds
    47  redis.4.8ryt076polmclyihzx67zsssj   redis:3.0.6  worker1   Running        Running 9 seconds
    48  redis.5.1x0v8yomsncd6sbvfn0ph6ogc   redis:3.0.6  manager1  Running        Running 8 seconds
    49  redis.6.71v7je3el7rrw0osfywzs0lko   redis:3.0.6  worker2   Running        Running 9 seconds
    50  redis.7.4l3zm9b7tfr7cedaik8roxq6r   redis:3.0.6  worker2   Running        Running 9 seconds
    51  redis.8.9tfpyixiy2i74ad9uqmzp1q6o   redis:3.0.6  worker1   Running        Running 9 seconds
    52  redis.9.3w1wu13yuplna8ri3fx47iwad   redis:3.0.6  manager1  Running        Running 8 seconds
    53  redis.10.8eaxrb2fqpbnv9x30vr06i6vt  redis:3.0.6  manager1  Running        Running 8 seconds
    54  ```
    55  
    56  When deploying a service, docker resolves the digest for the service's
    57  image, and pins the service to that digest. The digest is not shown by
    58  default, but is printed if `--no-trunc` is used;
    59  
    60  ```bash
    61  $ docker service ps --no-trunc redis
    62  NAME                                IMAGE                                                                                NODE      DESIRED STATE  CURRENT STATE
    63  redis.1.0qihejybwf1x5vqi8lgzlgnpq   redis:3.0.6@sha256:6a692a76c2081888b589e26e6ec835743119fe453d67ecf03df7de5b73d69842  manager1  Running        Running 28 seconds
    64  redis.2.bk658fpbex0d57cqcwoe3jthu   redis:3.0.6@sha256:6a692a76c2081888b589e26e6ec835743119fe453d67ecf03df7de5b73d69842  worker2   Running        Running 29 seconds
    65  redis.3.5ls5s5fldaqg37s9pwayjecrf   redis:3.0.6@sha256:6a692a76c2081888b589e26e6ec835743119fe453d67ecf03df7de5b73d69842  worker1   Running        Running 29 seconds
    66  redis.4.8ryt076polmclyihzx67zsssj   redis:3.0.6@sha256:6a692a76c2081888b589e26e6ec835743119fe453d67ecf03df7de5b73d69842  worker1   Running        Running 29 seconds
    67  redis.5.1x0v8yomsncd6sbvfn0ph6ogc   redis:3.0.6@sha256:6a692a76c2081888b589e26e6ec835743119fe453d67ecf03df7de5b73d69842  manager1  Running        Running 28 seconds
    68  redis.6.71v7je3el7rrw0osfywzs0lko   redis:3.0.6@sha256:6a692a76c2081888b589e26e6ec835743119fe453d67ecf03df7de5b73d69842  worker2   Running        Running 29 seconds
    69  redis.7.4l3zm9b7tfr7cedaik8roxq6r   redis:3.0.6@sha256:6a692a76c2081888b589e26e6ec835743119fe453d67ecf03df7de5b73d69842  worker2   Running        Running 29 seconds
    70  redis.8.9tfpyixiy2i74ad9uqmzp1q6o   redis:3.0.6@sha256:6a692a76c2081888b589e26e6ec835743119fe453d67ecf03df7de5b73d69842  worker1   Running        Running 29 seconds
    71  redis.9.3w1wu13yuplna8ri3fx47iwad   redis:3.0.6@sha256:6a692a76c2081888b589e26e6ec835743119fe453d67ecf03df7de5b73d69842  manager1  Running        Running 28 seconds
    72  redis.10.8eaxrb2fqpbnv9x30vr06i6vt  redis:3.0.6@sha256:6a692a76c2081888b589e26e6ec835743119fe453d67ecf03df7de5b73d69842  manager1  Running        Running 28 seconds
    73  ```
    74  
    75  ## Filtering
    76  
    77  The filtering flag (`-f` or `--filter`) format is a `key=value` pair. If there
    78  is more than one filter, then pass multiple flags (e.g. `--filter "foo=bar" --filter "bif=baz"`).
    79  Multiple filter flags are combined as an `OR` filter. For example,
    80  `-f name=redis.1 -f name=redis.7` returns both `redis.1` and `redis.7` tasks.
    81  
    82  The currently supported filters are:
    83  
    84  * [id](#id)
    85  * [name](#name)
    86  * [node](#node)
    87  * [desired-state](#desired-state)
    88  
    89  
    90  #### ID
    91  
    92  The `id` filter matches on all or a prefix of a task's ID.
    93  
    94  ```bash
    95  $ docker service ps -f "id=8" redis
    96  NAME                                IMAGE        NODE      DESIRED STATE  CURRENT STATE
    97  redis.4.8ryt076polmclyihzx67zsssj   redis:3.0.6  worker1   Running        Running 9 seconds
    98  redis.10.8eaxrb2fqpbnv9x30vr06i6vt  redis:3.0.6  manager1  Running        Running 8 seconds
    99  ```
   100  
   101  #### Name
   102  
   103  The `name` filter matches on task names.
   104  
   105  ```bash
   106  $ docker service ps -f "name=redis.1" redis
   107  NAME                                IMAGE        NODE      DESIRED STATE  CURRENT STATE
   108  redis.1.0qihejybwf1x5vqi8lgzlgnpq   redis:3.0.6  manager1  Running        Running 8 seconds
   109  ```
   110  
   111  
   112  #### Node
   113  
   114  The `node` filter matches on a node name or a node ID.
   115  
   116  ```bash
   117  $ docker service ps -f "node=manager1" redis
   118  NAME                                IMAGE        NODE      DESIRED STATE  CURRENT STATE
   119  redis.1.0qihejybwf1x5vqi8lgzlgnpq   redis:3.0.6  manager1  Running        Running 8 seconds
   120  redis.5.1x0v8yomsncd6sbvfn0ph6ogc   redis:3.0.6  manager1  Running        Running 8 seconds
   121  redis.9.3w1wu13yuplna8ri3fx47iwad   redis:3.0.6  manager1  Running        Running 8 seconds
   122  redis.10.8eaxrb2fqpbnv9x30vr06i6vt  redis:3.0.6  manager1  Running        Running 8 seconds
   123  ```
   124  
   125  
   126  #### desired-state
   127  
   128  The `desired-state` filter can take the values `running`, `shutdown`, and `accepted`.
   129  
   130  
   131  ## Related information
   132  
   133  * [service create](service_create.md)
   134  * [service inspect](service_inspect.md)
   135  * [service ls](service_ls.md)
   136  * [service rm](service_rm.md)
   137  * [service scale](service_scale.md)
   138  * [service update](service_update.md)