How do I get the status of a swarm service

I want to get the status of a docker swarm service.

docker inspect

sometime outputs what I need but often fails with “Error: No such image, container or task:”. It seems to depend on whether or not there is a task running with a name that starts with the service name in some way. Its as if it fails when the name is ambiguous,

docker service inspect

always works but the output doesn’t include the status.

OS is Suse Leap 42.2
Docker version 1.12.6

1 Like

Have you tried

docker service ls


docker service ps --no-trunc servicename

if it’s a stack you can use

docker stack ps --no-trunc stackname

The last one should give you the reason why it is not running. Personally i just use Shipyard to look at the logs of my failed services. Hope it helps.

The problems seem to have been the result of stopped or crashed containers not being removed when a service was removed. Cleaning up the docker engine by manually removing all containers seems to have resolved it. Now that I have got my services running properly the problems have gone away.