github.com/AliyunContainerService/cli@v0.0.0-20181009023821-814ced4b30d0/docs/reference/commandline/service_inspect.md (about)

     1  ---
     2  title: "service inspect"
     3  description: "The service inspect command description and usage"
     4  keywords: "service, inspect"
     5  ---
     6  
     7  <!-- This file is maintained within the docker/cli GitHub
     8       repository at https://github.com/docker/cli/. 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 inspect
    17  
    18  ```Markdown
    19  Usage:  docker service inspect [OPTIONS] SERVICE [SERVICE...]
    20  
    21  Display detailed information on one or more services
    22  
    23  Options:
    24    -f, --format string   Format the output using the given Go template
    25        --help            Print usage
    26        --pretty          Print the information in a human friendly format
    27  ```
    28  
    29  ## Description
    30  
    31  Inspects the specified service. This command has to be run targeting a manager
    32  node.
    33  
    34  By default, this renders all results in a JSON array. If a format is specified,
    35  the given template will be executed for each result.
    36  
    37  Go's [text/template](http://golang.org/pkg/text/template/) package
    38  describes all the details of the format.
    39  
    40  ## Examples
    41  
    42  ### Inspect a service by name or ID
    43  
    44  You can inspect a service, either by its *name*, or *ID*
    45  
    46  For example, given the following service;
    47  
    48  ```bash
    49  $ docker service ls
    50  ID            NAME   MODE        REPLICAS  IMAGE
    51  dmu1ept4cxcf  redis  replicated  3/3       redis:3.0.6
    52  ```
    53  
    54  Both `docker service inspect redis`, and `docker service inspect dmu1ept4cxcf`
    55  produce the same result:
    56  
    57  ```none
    58  $ docker service inspect redis
    59  
    60  [
    61      {
    62          "ID": "dmu1ept4cxcfe8k8lhtux3ro3",
    63          "Version": {
    64              "Index": 12
    65          },
    66          "CreatedAt": "2016-06-17T18:44:02.558012087Z",
    67          "UpdatedAt": "2016-06-17T18:44:02.558012087Z",
    68          "Spec": {
    69              "Name": "redis",
    70              "TaskTemplate": {
    71                  "ContainerSpec": {
    72                      "Image": "redis:3.0.6"
    73                  },
    74                  "Resources": {
    75                      "Limits": {},
    76                      "Reservations": {}
    77                  },
    78                  "RestartPolicy": {
    79                      "Condition": "any",
    80                      "MaxAttempts": 0
    81                  },
    82                  "Placement": {}
    83              },
    84              "Mode": {
    85                  "Replicated": {
    86                      "Replicas": 1
    87                  }
    88              },
    89              "UpdateConfig": {},
    90              "EndpointSpec": {
    91                  "Mode": "vip"
    92              }
    93          },
    94          "Endpoint": {
    95              "Spec": {}
    96          }
    97      }
    98  ]
    99  ```
   100  
   101  ```bash
   102  $ docker service inspect dmu1ept4cxcf
   103  
   104  [
   105      {
   106          "ID": "dmu1ept4cxcfe8k8lhtux3ro3",
   107          "Version": {
   108              "Index": 12
   109          },
   110          ...
   111      }
   112  ]
   113  ```
   114  
   115  ### Formatting
   116  
   117  You can print the inspect output in a human-readable format instead of the default
   118  JSON output, by using the `--pretty` option:
   119  
   120  ```bash
   121  $ docker service inspect --pretty frontend
   122  
   123  ID:		c8wgl7q4ndfd52ni6qftkvnnp
   124  Name:		frontend
   125  Labels:
   126   - org.example.projectname=demo-app
   127  Service Mode:	REPLICATED
   128   Replicas:		5
   129  Placement:
   130  UpdateConfig:
   131   Parallelism:	0
   132   On failure:	pause
   133   Max failure ratio:	0
   134  ContainerSpec:
   135   Image:		nginx:alpine
   136  Resources:
   137  Networks:	net1
   138  Endpoint Mode:  vip
   139  Ports:
   140   PublishedPort = 4443
   141    Protocol = tcp
   142    TargetPort = 443
   143    PublishMode = ingress
   144  ```
   145  
   146  You can also use `--format pretty` for the same effect.
   147  
   148  
   149  #### Find the number of tasks running as part of a service
   150  
   151  The `--format` option can be used to obtain specific information about a
   152  service. For example, the following command outputs the number of replicas
   153  of the "redis" service.
   154  
   155  ```bash
   156  $ docker service inspect --format='{{.Spec.Mode.Replicated.Replicas}}' redis
   157  
   158  10
   159  ```
   160  
   161  
   162  ## Related commands
   163  
   164  * [service create](service_create.md)
   165  * [service logs](service_logs.md)
   166  * [service ls](service_ls.md)
   167  * [service ps](service_ps.md)
   168  * [service rm](service_rm.md)
   169  * [service rollback](service_rollback.md)
   170  * [service scale](service_scale.md)
   171  * [service update](service_update.md)