mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
125 lines
3.5 KiB
Markdown
125 lines
3.5 KiB
Markdown
|
<!--[metadata]>
|
||
|
+++
|
||
|
title = "Inspect the service"
|
||
|
description = "Inspect the application"
|
||
|
keywords = ["tutorial, cluster management, swarm"]
|
||
|
[menu.main]
|
||
|
identifier="inspect-application"
|
||
|
parent="swarm-tutorial"
|
||
|
weight=17
|
||
|
advisory = "rc"
|
||
|
+++
|
||
|
<![end-metadata]-->
|
||
|
|
||
|
# Inspect a service on the Swarm
|
||
|
|
||
|
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.
|
||
|
|
||
|
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`.
|
||
|
|
||
|
2. Run `docker service inspect --pretty SERVICE-ID` to display the details about
|
||
|
a service in an easily readable format.
|
||
|
|
||
|
To see the details on the `helloworld` service:
|
||
|
```
|
||
|
$ docker service inspect --pretty helloworld
|
||
|
|
||
|
ID: 2zs4helqu64f3k3iuwywbk49w
|
||
|
Name: helloworld
|
||
|
Mode: REPLICATED
|
||
|
Scale: 1
|
||
|
Placement:
|
||
|
Strategy: SPREAD
|
||
|
UpateConfig:
|
||
|
Parallelism: 1
|
||
|
ContainerSpec:
|
||
|
Image: alpine
|
||
|
Command: ping docker.com
|
||
|
```
|
||
|
|
||
|
>**Tip**: To return the service details in json format, run the same command
|
||
|
without the `--pretty` flag.
|
||
|
|
||
|
```
|
||
|
$ docker service inspect helloworld
|
||
|
[
|
||
|
{
|
||
|
"ID": "2zs4helqu64f3k3iuwywbk49w",
|
||
|
"Version": {
|
||
|
"Index": 16264
|
||
|
},
|
||
|
"CreatedAt": "2016-06-06T17:41:11.509146705Z",
|
||
|
"UpdatedAt": "2016-06-06T17:41:11.510426385Z",
|
||
|
"Spec": {
|
||
|
"Name": "helloworld",
|
||
|
"ContainerSpec": {
|
||
|
"Image": "alpine",
|
||
|
"Command": [
|
||
|
"ping",
|
||
|
"docker.com"
|
||
|
],
|
||
|
"Resources": {
|
||
|
"Limits": {},
|
||
|
"Reservations": {}
|
||
|
}
|
||
|
},
|
||
|
"Mode": {
|
||
|
"Replicated": {
|
||
|
"Instances": 1
|
||
|
}
|
||
|
},
|
||
|
"RestartPolicy": {},
|
||
|
"Placement": {},
|
||
|
"UpdateConfig": {
|
||
|
"Parallelism": 1
|
||
|
},
|
||
|
"EndpointSpec": {}
|
||
|
},
|
||
|
"Endpoint": {
|
||
|
"Spec": {}
|
||
|
}
|
||
|
}
|
||
|
]
|
||
|
```
|
||
|
|
||
|
4. Run `docker service tasks SERVICE-ID` to see which nodes are running the
|
||
|
service:
|
||
|
|
||
|
```
|
||
|
$ docker service tasks helloworld
|
||
|
|
||
|
ID NAME SERVICE IMAGE DESIRED STATE LAST STATE NODE
|
||
|
1n6wif51j0w840udalgw6hphg helloworld.1 helloworld alpine RUNNING RUNNING 19 minutes manager1
|
||
|
```
|
||
|
|
||
|
In this case, the one instance of the `helloworld` service is running on the
|
||
|
`manager1` node. Manager nodes in a Swarm can execute tasks just like worker
|
||
|
nodes.
|
||
|
|
||
|
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.
|
||
|
|
||
|
4. Run `docker ps` on the node where the instance of the service is running to
|
||
|
see the service container.
|
||
|
|
||
|
>**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
|
||
|
a0b6c02868ca alpine:latest "ping docker.com" 12 minutes ago Up 12 minutes helloworld.1.1n6wif51j0w840udalgw6hphg
|
||
|
```
|
||
|
|
||
|
## What's next?
|
||
|
|
||
|
Next, you can [change the scale](scale-service.md) for the service running in
|
||
|
the Swarm.
|
||
|
|
||
|
<p style="margin-bottom:300px"> </p>
|