Signed-off-by: Charles Smith <charles.smith@docker.com>
3.5 KiB
Inspect a service on the Swarm
When you have deployed a service to your Swarm, you can use the Docker CLI to see details about the service running in the Swarm.
-
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
. -
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": {} } } ]
-
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 themanager1
node. Manager nodes in a Swarm can execute tasks just like worker nodes.Swarm also shows you the
DESIRED STATE
andLAST STATE
of the service task so you can see if tasks are running according to the service definition. -
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.$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 for the service running in the Swarm.