2016-10-14 18:30:36 -04:00
|
|
|
---
|
|
|
|
title: "service inspect"
|
|
|
|
description: "The service inspect command description and usage"
|
2016-11-03 18:48:30 -04:00
|
|
|
keywords: "service, inspect"
|
2016-10-14 18:30:36 -04:00
|
|
|
---
|
2016-06-17 19:51:17 -04:00
|
|
|
|
2016-10-19 13:25:45 -04:00
|
|
|
<!-- This file is maintained within the docker/docker Github
|
|
|
|
repository at https://github.com/docker/docker/. Make all
|
|
|
|
pull requests against that repo. If you see this file in
|
|
|
|
another repository, consider it read-only there, as it will
|
|
|
|
periodically be overwritten by the definitive file. Pull
|
|
|
|
requests which include edits to this file in other repositories
|
|
|
|
will be rejected.
|
|
|
|
-->
|
|
|
|
|
2016-06-17 19:51:17 -04:00
|
|
|
# service inspect
|
|
|
|
|
|
|
|
```Markdown
|
2016-07-07 14:43:18 -04:00
|
|
|
Usage: docker service inspect [OPTIONS] SERVICE [SERVICE...]
|
2016-06-17 19:51:17 -04:00
|
|
|
|
2016-06-30 08:13:28 -04:00
|
|
|
Display detailed information on one or more services
|
2016-06-17 19:51:17 -04:00
|
|
|
|
|
|
|
Options:
|
2016-10-18 06:50:11 -04:00
|
|
|
-f, --format string Format the output using the given Go template
|
2016-06-17 19:51:17 -04:00
|
|
|
--help Print usage
|
2016-07-13 12:46:17 -04:00
|
|
|
--pretty Print the information in a human friendly format.
|
2016-06-17 19:51:17 -04:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
Inspects the specified service. This command has to be run targeting a manager
|
|
|
|
node.
|
|
|
|
|
|
|
|
By default, this renders all results in a JSON array. If a format is specified,
|
|
|
|
the given template will be executed for each result.
|
|
|
|
|
|
|
|
Go's [text/template](http://golang.org/pkg/text/template/) package
|
|
|
|
describes all the details of the format.
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
|
|
### Inspecting a service by name or ID
|
|
|
|
|
|
|
|
You can inspect a service, either by its *name*, or *ID*
|
|
|
|
|
|
|
|
For example, given the following service;
|
|
|
|
|
|
|
|
```bash
|
|
|
|
$ docker service ls
|
2016-11-03 14:20:53 -04:00
|
|
|
ID NAME REPLICAS IMAGE
|
2016-06-17 19:51:17 -04:00
|
|
|
dmu1ept4cxcf redis 3/3 redis:3.0.6
|
|
|
|
```
|
|
|
|
|
|
|
|
Both `docker service inspect redis`, and `docker service inspect dmu1ept4cxcf`
|
|
|
|
produce the same result:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
$ docker service inspect redis
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"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": {}
|
|
|
|
},
|
|
|
|
"RestartPolicy": {
|
|
|
|
"Condition": "any",
|
|
|
|
"MaxAttempts": 0
|
|
|
|
},
|
|
|
|
"Placement": {}
|
|
|
|
},
|
|
|
|
"Mode": {
|
|
|
|
"Replicated": {
|
|
|
|
"Replicas": 1
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"UpdateConfig": {},
|
|
|
|
"EndpointSpec": {
|
|
|
|
"Mode": "vip"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"Endpoint": {
|
|
|
|
"Spec": {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
```
|
|
|
|
|
|
|
|
```bash
|
|
|
|
$ docker service inspect dmu1ept4cxcf
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"ID": "dmu1ept4cxcfe8k8lhtux3ro3",
|
|
|
|
"Version": {
|
|
|
|
"Index": 12
|
|
|
|
},
|
|
|
|
...
|
|
|
|
}
|
|
|
|
]
|
|
|
|
```
|
|
|
|
|
|
|
|
### Inspect a service using pretty-print
|
|
|
|
|
|
|
|
You can print the inspect output in a human-readable format instead of the default
|
|
|
|
JSON output, by using the `--pretty` option:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
$ docker service inspect --pretty frontend
|
|
|
|
ID: c8wgl7q4ndfd52ni6qftkvnnp
|
|
|
|
Name: frontend
|
|
|
|
Labels:
|
|
|
|
- org.example.projectname=demo-app
|
2016-09-25 04:47:45 -04:00
|
|
|
Service Mode: REPLICATED
|
2016-06-17 19:51:17 -04:00
|
|
|
Replicas: 5
|
|
|
|
Placement:
|
|
|
|
UpdateConfig:
|
|
|
|
Parallelism: 0
|
|
|
|
ContainerSpec:
|
|
|
|
Image: nginx:alpine
|
|
|
|
Resources:
|
2016-09-25 04:47:45 -04:00
|
|
|
Endpoint Mode: vip
|
2016-06-17 19:51:17 -04:00
|
|
|
Ports:
|
|
|
|
Name =
|
|
|
|
Protocol = tcp
|
|
|
|
TargetPort = 443
|
|
|
|
PublishedPort = 4443
|
|
|
|
```
|
|
|
|
|
2016-07-25 15:24:34 -04:00
|
|
|
You can also use `--format pretty` for the same effect.
|
|
|
|
|
2016-06-17 19:51:17 -04:00
|
|
|
|
|
|
|
### Finding the number of tasks running as part of a service
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
2016-10-19 13:25:45 -04:00
|
|
|
```bash{% raw %}
|
2016-06-17 19:51:17 -04:00
|
|
|
$ docker service inspect --format='{{.Spec.Mode.Replicated.Replicas}}' redis
|
|
|
|
10
|
2016-10-19 13:25:45 -04:00
|
|
|
{% endraw %}```
|
2016-06-17 19:51:17 -04:00
|
|
|
|
|
|
|
|
|
|
|
## Related information
|
|
|
|
|
|
|
|
* [service create](service_create.md)
|
|
|
|
* [service ls](service_ls.md)
|
|
|
|
* [service rm](service_rm.md)
|
|
|
|
* [service scale](service_scale.md)
|
2016-07-19 17:01:31 -04:00
|
|
|
* [service ps](service_ps.md)
|
2016-06-17 19:51:17 -04:00
|
|
|
* [service update](service_update.md)
|