github.com/yogeshlonkar/moby@v1.13.2-0.20201203103638-c0b64beaea94/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/docker Github 8 repository at https://github.com/docker/docker/. 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 ContainerSpec: 133 Image: nginx:alpine 134 Resources: 135 Endpoint Mode: vip 136 Ports: 137 Name = 138 Protocol = tcp 139 TargetPort = 443 140 PublishedPort = 4443 141 ``` 142 143 You can also use `--format pretty` for the same effect. 144 145 146 #### Find the number of tasks running as part of a service 147 148 The `--format` option can be used to obtain specific information about a 149 service. For example, the following command outputs the number of replicas 150 of the "redis" service. 151 152 ```bash 153 $ docker service inspect --format='{{.Spec.Mode.Replicated.Replicas}}' redis 154 155 10 156 ``` 157 158 159 ## Related commands 160 161 * [service create](service_create.md) 162 * [service logs](service_logs.md) 163 * [service ls](service_ls.md) 164 * [service rm](service_rm.md) 165 * [service scale](service_scale.md) 166 * [service ps](service_ps.md) 167 * [service update](service_update.md)