Docker Swarm provides a nice way to configure container health checks in the Docker file or a stack compose file. Health status of a container can be checked using docker inspect <container> or just docker ps on the hosting machine.

However, I would like to know the status of a Docker Service, specifically in the docker service ls or ps commands. How can I check that health status of a service (i.e. one or more replicas of a container) in a Docker Swarm deployment?

docker service ps <service> shows that status of the deployed containers in a service but does not seem to show the health status of either each replica or the service overall (however that is meant to be interpreted).

Thanks in advance for any suggestions.

PS It's clunky and slow (since it has to execute a command for each node on which a service container is deployed) but this is a script that sort of does what I hoped would be able to see with docker service ps

#! /bin/sh
hosts=`docker service ps -f desired-state=running --format "{{ .Node }} " $1`
echo "${1}:"
for host in ${hosts}
    /bin/echo -n "${host} - "
    docker-machine ssh ${host} "sudo docker ps -f name=\"${1}\" --format \"{{ .Status }} \""
  • 1
    The Swarm documentaiton seems to describe the solution to this question - what is missing from it that makes you feel it's inadequate? – Bruce Becker Nov 4 '18 at 13:52
  • Could you reply to the comment? – 030 Dec 23 '19 at 9:03
  • Sorry @BruceBecker (and 030...) that's almost two years now and I've swapped out all details. No time to go back atm, hope the documentation does help. – Ashley Aitken Jan 19 at 12:50

Browse other questions tagged or ask your own question.