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 }} \""
  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.