github.com/brahmaroutu/docker@v1.2.1-0.20160809185609-eb28dde01f16/docs/reference/commandline/service_inspect.md (about)

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