summaryrefslogtreecommitdiff
path: root/devdocs/docker/engine%2Fswarm%2Fswarm-tutorial%2Finspect-service%2Findex.html
blob: 47a9100071a7582e8b4b294057a077693e71e2f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<h1>Inspect a service on the swarm</h1>

<p>When you have <a href="../deploy-service/index">deployed a service</a> to your swarm, you can use the Docker CLI to see details about the service running in the swarm.</p> <ol> <li> <p>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 <code class="language-plaintext highlighter-rouge">manager1</code>.</p> </li> <li> <p>Run <code class="language-plaintext highlighter-rouge">docker service inspect --pretty &lt;SERVICE-ID&gt;</code> to display the details about a service in an easily readable format.</p> <p>To see the details on the <code class="language-plaintext highlighter-rouge">helloworld</code> service:</p> <div class="highlight"><pre class="highlight" data-language="">[manager1]$ docker service inspect --pretty helloworld

ID:		9uk4639qpg7npwf3fn2aasksr
Name:		helloworld
Service Mode:	REPLICATED
 Replicas:		1
Placement:
UpdateConfig:
 Parallelism:	1
ContainerSpec:
 Image:		alpine
 Args:	ping docker.com
Resources:
Endpoint Mode:  vip
</pre></div>  <blockquote> <p><strong>Tip</strong>: To return the service details in json format, run the same command without the <code class="language-plaintext highlighter-rouge">--pretty</code> flag.</p> </blockquote> <div class="highlight"><pre class="highlight" data-language="">[manager1]$ docker service inspect helloworld
[
{
    "ID": "9uk4639qpg7npwf3fn2aasksr",
    "Version": {
        "Index": 418
    },
    "CreatedAt": "2016-06-16T21:57:11.622222327Z",
    "UpdatedAt": "2016-06-16T21:57:11.622222327Z",
    "Spec": {
        "Name": "helloworld",
        "TaskTemplate": {
            "ContainerSpec": {
                "Image": "alpine",
                "Args": [
                    "ping",
                    "docker.com"
                ]
            },
            "Resources": {
                "Limits": {},
                "Reservations": {}
            },
            "RestartPolicy": {
                "Condition": "any",
                "MaxAttempts": 0
            },
            "Placement": {}
        },
        "Mode": {
            "Replicated": {
                "Replicas": 1
            }
        },
        "UpdateConfig": {
            "Parallelism": 1
        },
        "EndpointSpec": {
            "Mode": "vip"
        }
    },
    "Endpoint": {
        "Spec": {}
    }
}
]
</pre></div>  </li> <li> <p>Run <code class="language-plaintext highlighter-rouge">docker service ps &lt;SERVICE-ID&gt;</code> to see which nodes are running the service:</p> <div class="highlight"><pre class="highlight" data-language="">[manager1]$ docker service ps helloworld

NAME                                    IMAGE   NODE     DESIRED STATE  CURRENT STATE           ERROR               PORTS
helloworld.1.8p1vev3fq5zm0mi8g0as41w35  alpine  worker2  Running        Running 3 minutes
</pre></div>  <p>In this case, the one instance of the <code class="language-plaintext highlighter-rouge">helloworld</code> service is running on the <code class="language-plaintext highlighter-rouge">worker2</code> node. You may see the service running on your manager node. By default, manager nodes in a swarm can execute tasks just like worker nodes.</p> <p>Swarm also shows you the <code class="language-plaintext highlighter-rouge">DESIRED STATE</code> and <code class="language-plaintext highlighter-rouge">CURRENT STATE</code> of the service task so you can see if tasks are running according to the service definition.</p> </li> <li> <p>Run <code class="language-plaintext highlighter-rouge">docker ps</code> on the node where the task is running to see details about the container for the task.</p> <blockquote> <p><strong>Tip</strong>: If <code class="language-plaintext highlighter-rouge">helloworld</code> is running on a node other than your manager node, you must ssh to that node.</p> </blockquote> <div class="highlight"><pre class="highlight" data-language="">[worker2]$ docker ps

CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
e609dde94e47        alpine:latest       "ping docker.com"   3 minutes ago       Up 3 minutes                            helloworld.1.8p1vev3fq5zm0mi8g0as41w35
</pre></div>  </li> </ol> <h2 id="whats-next">What’s next?</h2> <p>Next, you can <a href="../scale-service/index">change the scale</a> for the service running in the swarm.</p> 
<p><a href="https://docs.docker.com/search/?q=tutorial">tutorial</a>, <a href="https://docs.docker.com/search/?q=cluster%20management">cluster management</a>, <a href="https://docs.docker.com/search/?q=swarm%20mode">swarm mode</a></p>
<div class="_attribution">
  <p class="_attribution-p">
    &copy; 2019 Docker, Inc.<br>Licensed under the Apache License, Version 2.0.<br>Docker and the Docker logo are trademarks or registered trademarks of Docker, Inc. in the United States and/or other countries.<br>Docker, Inc. and other parties may also have trademark rights in other terms used herein.<br>
    <a href="https://docs.docker.com/engine/swarm/swarm-tutorial/inspect-service/" class="_attribution-link">https://docs.docker.com/engine/swarm/swarm-tutorial/inspect-service/</a>
  </p>
</div>