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}
do
/bin/echo -n "${host} - "
docker-machine ssh ${host} "sudo docker ps -f name=\"${1}\" --format \"{{ .Status }} \""
done