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