Display detailed information on one or more services
docker service inspect [OPTIONS] SERVICE [SERVICE...]
Name, shorthand | Default | Description |
---|---|---|
--format, -f |
Format the output using the given Go template | |
--pretty |
false |
Print the information in a human friendly format. |
Command | Description |
---|---|
docker service | Manage services |
Command | Description |
---|---|
docker service create | Create a new service |
docker service inspect | Display detailed information on one or more services |
docker service logs | Fetch the logs of a service |
docker service ls | List services |
docker service ps | List the tasks of one or more services |
docker service rm | Remove one or more services |
docker service scale | Scale one or multiple replicated services |
docker service update | Update a service |
You can inspect a service, either by its name, or ID
For example, given the following service;
$ docker service ls
ID NAME MODE REPLICAS IMAGE
dmu1ept4cxcf redis replicated 3/3 redis:3.0.6
Both docker service inspect redis
, and docker service inspect dmu1ept4cxcf
produce the same result:
$ 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": {}
}
}
]
$ docker service inspect dmu1ept4cxcf
[
{
"ID": "dmu1ept4cxcfe8k8lhtux3ro3",
"Version": {
"Index": 12
},
...
}
]
You can print the inspect output in a human-readable format instead of the default
JSON output, by using the --pretty
option:
$ docker service inspect --pretty frontend
ID: c8wgl7q4ndfd52ni6qftkvnnp
Name: frontend
Labels:
- org.example.projectname=demo-app
Service Mode: REPLICATED
Replicas: 5
Placement:
UpdateConfig:
Parallelism: 0
ContainerSpec:
Image: nginx:alpine
Resources:
Endpoint Mode: vip
Ports:
Name =
Protocol = tcp
TargetPort = 443
PublishedPort = 4443
You can also use --format pretty
for the same effect.
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.
$ docker service inspect --format='{{.Spec.Mode.Replicated.Replicas}}' redis
10