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