2016-06-17 19:51:17 -04:00
# service inspect
2023-01-06 13:04:05 -05:00
<!-- - MARKER_GEN_START -->
2016-06-30 08:13:28 -04:00
Display detailed information on one or more services
2016-06-17 19:51:17 -04:00
2023-01-06 13:04:05 -05:00
### Options
| Name | Type | Default | Description |
|:---------------------------------------|:---------|:--------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [`-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 |
| [`--pretty` ](#pretty ) | | | Print the information in a human friendly format |
<!-- - MARKER_GEN_END -->
2016-06-17 19:51:17 -04:00
2017-02-07 18:42:48 -05:00
## Description
2016-06-17 19:51:17 -04:00
2018-12-23 06:27:52 -05:00
Inspects the specified service.
2016-06-17 19:51:17 -04:00
By default, this renders all results in a JSON array. If a format is specified,
the given template will be executed for each result.
2021-10-14 18:04:36 -04:00
Go's [text/template ](https://golang.org/pkg/text/template/ ) package
2016-06-17 19:51:17 -04:00
describes all the details of the format.
2020-04-19 11:08:37 -04:00
> **Note**
>
> This is a cluster management command, and must be executed on a swarm
> manager node. To learn about managers and workers, refer to the
> [Swarm mode section](https://docs.docker.com/engine/swarm/) in the
> documentation.
2018-12-23 06:27:52 -05:00
2016-06-17 19:51:17 -04:00
## Examples
2017-02-07 18:42:48 -05:00
### Inspect a service by name or ID
2016-06-17 19:51:17 -04:00
You can inspect a service, either by its *name* , or *ID*
For example, given the following service;
2021-08-21 08:54:14 -04:00
```console
2016-06-17 19:51:17 -04:00
$ docker service ls
2016-10-24 23:39:53 -04:00
ID NAME MODE REPLICAS IMAGE
dmu1ept4cxcf redis replicated 3/3 redis:3.0.6
2016-06-17 19:51:17 -04:00
```
Both `docker service inspect redis` , and `docker service inspect dmu1ept4cxcf`
produce the same result:
2021-08-21 08:54:14 -04:00
```console
2016-06-17 19:51:17 -04:00
$ docker service inspect redis
2020-05-11 11:32:52 -04:00
```
The output is in JSON format, for example:
2017-02-07 18:42:48 -05:00
2020-05-11 11:32:52 -04:00
```json
2016-06-17 19:51:17 -04:00
[
2020-04-19 09:43:08 -04:00
{
"ID": "dmu1ept4cxcfe8k8lhtux3ro3",
"Version": {
"Index": 12
},
"CreatedAt": "2016-06-17T18:44:02.558012087Z",
"UpdatedAt": "2016-06-17T18:44:02.558012087Z",
"Spec": {
"Name": "redis",
"TaskTemplate": {
"ContainerSpec": {
"Image": "redis:3.0.6"
},
"Resources": {
"Limits": {},
"Reservations": {}
2016-06-17 19:51:17 -04:00
},
2020-04-19 09:43:08 -04:00
"RestartPolicy": {
"Condition": "any",
"MaxAttempts": 0
2016-06-17 19:51:17 -04:00
},
2020-04-19 09:43:08 -04:00
"Placement": {}
},
"Mode": {
"Replicated": {
"Replicas": 1
2016-06-17 19:51:17 -04:00
}
2020-04-19 09:43:08 -04:00
},
"UpdateConfig": {},
"EndpointSpec": {
"Mode": "vip"
}
},
"Endpoint": {
"Spec": {}
2016-06-17 19:51:17 -04:00
}
2020-04-19 09:43:08 -04:00
}
2016-06-17 19:51:17 -04:00
]
```
2021-08-21 08:54:14 -04:00
```console
2016-06-17 19:51:17 -04:00
$ docker service inspect dmu1ept4cxcf
2017-02-07 18:42:48 -05:00
2016-06-17 19:51:17 -04:00
[
2020-04-19 09:43:08 -04:00
{
"ID": "dmu1ept4cxcfe8k8lhtux3ro3",
"Version": {
"Index": 12
},
...
}
2016-06-17 19:51:17 -04:00
]
```
2023-01-06 13:28:29 -05:00
### <a name="pretty"></a> Formatting (--pretty)
2016-06-17 19:51:17 -04:00
You can print the inspect output in a human-readable format instead of the default
JSON output, by using the `--pretty` option:
2021-08-21 08:54:14 -04:00
```console
2016-06-17 19:51:17 -04:00
$ docker service inspect --pretty frontend
2017-02-07 18:42:48 -05:00
2020-03-15 10:11:43 -04:00
ID: c8wgl7q4ndfd52ni6qftkvnnp
Name: frontend
2016-06-17 19:51:17 -04:00
Labels:
- org.example.projectname=demo-app
2020-03-15 10:11:43 -04:00
Service Mode: REPLICATED
Replicas: 5
2016-06-17 19:51:17 -04:00
Placement:
UpdateConfig:
2020-03-15 10:11:43 -04:00
Parallelism: 0
On failure: pause
Max failure ratio: 0
2016-06-17 19:51:17 -04:00
ContainerSpec:
2020-03-15 10:11:43 -04:00
Image: nginx:alpine
2016-06-17 19:51:17 -04:00
Resources:
2020-03-15 10:11:43 -04:00
Networks: net1
2016-09-25 04:47:45 -04:00
Endpoint Mode: vip
2016-06-17 19:51:17 -04:00
Ports:
PublishedPort = 4443
2017-01-05 14:21:22 -05:00
Protocol = tcp
TargetPort = 443
PublishMode = ingress
2016-06-17 19:51:17 -04:00
```
2016-07-25 15:24:34 -04:00
You can also use `--format pretty` for the same effect.
2023-01-06 13:28:29 -05:00
### <a name="format"></a> Format the output (--format)
2016-06-17 19:51:17 -04:00
2023-01-06 12:05:02 -05:00
You can use the --format option to obtain specific information about a
2016-06-17 19:51:17 -04:00
The `--format` option can be used to obtain specific information about a
service. For example, the following command outputs the number of replicas
of the "redis" service.
2021-08-21 08:54:14 -04:00
```console
2016-06-17 19:51:17 -04:00
$ docker service inspect --format='{{.Spec.Mode.Replicated.Replicas}}' redis
2017-02-07 18:42:48 -05:00
2016-06-17 19:51:17 -04:00
10
2017-02-07 18:42:48 -05:00
```
2016-06-17 19:51:17 -04:00
2017-02-07 18:42:48 -05:00
## Related commands
2016-06-17 19:51:17 -04:00
* [service create ](service_create.md )
2016-12-14 06:30:09 -05:00
* [service logs ](service_logs.md )
2016-06-17 19:51:17 -04:00
* [service ls ](service_ls.md )
2017-07-20 04:32:51 -04:00
* [service ps ](service_ps.md )
2016-06-17 19:51:17 -04:00
* [service rm ](service_rm.md )
2017-07-20 04:32:51 -04:00
* [service rollback ](service_rollback.md )
2016-06-17 19:51:17 -04:00
* [service scale ](service_scale.md )
* [service update ](service_update.md )