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