Signed-off-by: Charles Smith <charles.smith@docker.com> Upstream-commit: ea4fef2d875de39044ca7570c35365b75086e8a5 Component: engine
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-IDto display the details about a service in an easily readable format.To see the details on the
helloworldservice:$ 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.comTip
: To return the service details in json format, run the same command without the
--prettyflag.$ 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-IDto 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 manager1In this case, the one instance of the
helloworldservice is running on themanager1node. Manager nodes in a Swarm can execute tasks just like worker nodes.Swarm also shows you the
DESIRED STATEandLAST STATEof the service task so you can see if tasks are running according to the service definition. -
Run
docker pson the node where the instance of the service is running to see the service container.Tip
: If
helloworldis 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.