2016-06-07 20:08:36 -04:00
|
|
|
<!--[metadata]>
|
|
|
|
+++
|
|
|
|
title = "Inspect the service"
|
|
|
|
description = "Inspect the application"
|
2016-06-15 16:26:13 -04:00
|
|
|
keywords = ["tutorial, cluster management, swarm mode"]
|
2016-06-07 20:08:36 -04:00
|
|
|
[menu.main]
|
|
|
|
identifier="inspect-application"
|
|
|
|
parent="swarm-tutorial"
|
|
|
|
weight=17
|
|
|
|
+++
|
|
|
|
<![end-metadata]-->
|
|
|
|
|
2016-06-15 16:26:13 -04:00
|
|
|
# Inspect a service on the swarm
|
2016-06-07 20:08:36 -04:00
|
|
|
|
2016-06-15 16:26:13 -04:00
|
|
|
When you have [deployed a service](deploy-service.md) to your swarm, you can use
|
|
|
|
the Docker CLI to see details about the service running in the swarm.
|
2016-06-07 20:08:36 -04:00
|
|
|
|
|
|
|
1. If you haven't already, open a terminal and ssh into the machine where you
|
|
|
|
run your manager node. For example, the tutorial uses a machine named
|
|
|
|
`manager1`.
|
|
|
|
|
2016-06-14 19:29:10 -04:00
|
|
|
2. Run `docker service inspect --pretty <SERVICE-ID>` to display the details
|
|
|
|
about a service in an easily readable format.
|
2016-06-07 20:08:36 -04:00
|
|
|
|
|
|
|
To see the details on the `helloworld` service:
|
2016-06-14 19:29:10 -04:00
|
|
|
|
2016-06-07 20:08:36 -04:00
|
|
|
```
|
|
|
|
$ docker service inspect --pretty helloworld
|
|
|
|
|
2016-06-15 16:26:13 -04:00
|
|
|
ID: 9uk4639qpg7npwf3fn2aasksr
|
2016-06-07 20:08:36 -04:00
|
|
|
Name: helloworld
|
|
|
|
Mode: REPLICATED
|
2016-06-15 16:26:13 -04:00
|
|
|
Replicas: 1
|
2016-06-07 20:08:36 -04:00
|
|
|
Placement:
|
2016-06-14 19:29:10 -04:00
|
|
|
UpdateConfig:
|
2016-06-07 20:08:36 -04:00
|
|
|
Parallelism: 1
|
|
|
|
ContainerSpec:
|
|
|
|
Image: alpine
|
2016-06-15 16:26:13 -04:00
|
|
|
Args: ping docker.com
|
2016-06-07 20:08:36 -04:00
|
|
|
```
|
|
|
|
|
|
|
|
>**Tip**: To return the service details in json format, run the same command
|
|
|
|
without the `--pretty` flag.
|
|
|
|
|
|
|
|
```
|
|
|
|
$ docker service inspect helloworld
|
|
|
|
[
|
|
|
|
{
|
2016-06-15 16:26:13 -04:00
|
|
|
"ID": "9uk4639qpg7npwf3fn2aasksr",
|
2016-06-07 20:08:36 -04:00
|
|
|
"Version": {
|
2016-06-15 16:26:13 -04:00
|
|
|
"Index": 418
|
2016-06-07 20:08:36 -04:00
|
|
|
},
|
2016-06-15 16:26:13 -04:00
|
|
|
"CreatedAt": "2016-06-16T21:57:11.622222327Z",
|
|
|
|
"UpdatedAt": "2016-06-16T21:57:11.622222327Z",
|
2016-06-07 20:08:36 -04:00
|
|
|
"Spec": {
|
|
|
|
"Name": "helloworld",
|
2016-06-15 16:26:13 -04:00
|
|
|
"TaskTemplate": {
|
|
|
|
"ContainerSpec": {
|
|
|
|
"Image": "alpine",
|
|
|
|
"Args": [
|
|
|
|
"ping",
|
|
|
|
"docker.com"
|
|
|
|
]
|
|
|
|
},
|
2016-06-07 20:08:36 -04:00
|
|
|
"Resources": {
|
|
|
|
"Limits": {},
|
|
|
|
"Reservations": {}
|
2016-06-15 16:26:13 -04:00
|
|
|
},
|
|
|
|
"RestartPolicy": {
|
|
|
|
"Condition": "any",
|
|
|
|
"MaxAttempts": 0
|
|
|
|
},
|
|
|
|
"Placement": {}
|
2016-06-07 20:08:36 -04:00
|
|
|
},
|
|
|
|
"Mode": {
|
|
|
|
"Replicated": {
|
2016-06-15 16:26:13 -04:00
|
|
|
"Replicas": 1
|
2016-06-07 20:08:36 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
"UpdateConfig": {
|
|
|
|
"Parallelism": 1
|
|
|
|
},
|
2016-06-15 16:26:13 -04:00
|
|
|
"EndpointSpec": {
|
|
|
|
"Mode": "vip"
|
|
|
|
}
|
2016-06-07 20:08:36 -04:00
|
|
|
},
|
|
|
|
"Endpoint": {
|
|
|
|
"Spec": {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
```
|
|
|
|
|
2016-07-19 17:01:31 -04:00
|
|
|
4. Run `docker service ps <SERVICE-ID>` to see which nodes are running the
|
2016-06-07 20:08:36 -04:00
|
|
|
service:
|
|
|
|
|
|
|
|
```
|
2016-07-19 17:01:31 -04:00
|
|
|
$ docker service ps helloworld
|
2016-06-07 20:08:36 -04:00
|
|
|
|
2016-06-15 16:26:13 -04:00
|
|
|
ID NAME SERVICE IMAGE LAST STATE DESIRED STATE NODE
|
|
|
|
8p1vev3fq5zm0mi8g0as41w35 helloworld.1 helloworld alpine Running 3 minutes Running worker2
|
2016-06-07 20:08:36 -04:00
|
|
|
```
|
|
|
|
|
|
|
|
In this case, the one instance of the `helloworld` service is running on the
|
2016-06-15 16:26:13 -04:00
|
|
|
`worker2` node. You may see the service running on your manager node. By
|
2016-07-25 19:24:32 -04:00
|
|
|
default, manager nodes in a swarm can execute tasks just like worker nodes.
|
2016-06-07 20:08:36 -04:00
|
|
|
|
|
|
|
Swarm also shows you the `DESIRED STATE` and `LAST STATE` of the service
|
|
|
|
task so you can see if tasks are running according to the service
|
|
|
|
definition.
|
|
|
|
|
2016-06-15 16:26:13 -04:00
|
|
|
4. Run `docker ps` on the node where the task is running to see details about
|
|
|
|
the container for the task.
|
2016-06-07 20:08:36 -04:00
|
|
|
|
|
|
|
>**Tip**: If `helloworld` is running on a node other than your manager node,
|
|
|
|
you must ssh to that node.
|
|
|
|
|
|
|
|
```bash
|
|
|
|
$docker ps
|
|
|
|
|
|
|
|
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
2016-06-15 16:26:13 -04:00
|
|
|
e609dde94e47 alpine:latest "ping docker.com" 3 minutes ago Up 3 minutes helloworld.1.8p1vev3fq5zm0mi8g0as41w35
|
2016-06-07 20:08:36 -04:00
|
|
|
```
|
|
|
|
|
|
|
|
## What's next?
|
|
|
|
|
|
|
|
Next, you can [change the scale](scale-service.md) for the service running in
|
2016-06-15 16:26:13 -04:00
|
|
|
the swarm.
|