<p>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 <code>docker inspect &lt;container&gt;</code> or just <code>docker ps</code> on the hosting machine.</p>

<p>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?  </p>

<p><code>docker service ps &lt;service&gt;</code> 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).</p>

<p>Thanks in advance for any suggestions.</p>

<p>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 <code>docker service ps</code></p>

<pre><code>#! /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
</code></pre>

CC BY-SA 4.0
2018-11-04T13:52:44.147Z
The [Swarm documentaiton](https://docs.docker.com/engine/swarm/admin_guide/#monitor-swarm-health) seems to describe the solution to this question - what is missing from it that makes you feel it's inadequate?
Bruce Becker
CC BY-SA 4.0
2019-12-23T09:03:15.000Z
Could you reply to the comment?
030
CC BY-SA 4.0
2020-01-19T12:50:48.920Z
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
CC BY-SA 4.0
2020-05-04T03:44:18.693Z
@BruceBecker that is about the node's health, not that of a service or task
nafg
<docker-swarm>
Docker Swarm Service Health Check?
Ashley Aitken
# Docker Swarm Service Health Check?

(Asked by: username_0 on 2018-03-15)

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  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  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

**Tags:** docker-swarm

> **Comments:**
> **username_1**: The [Swarm documentaiton](https://docs.docker.com/engine/swarm/admin_guide/#monitor-swarm-health) seems to describe the solution to this question - what is missing from it that makes you feel it's inadequate?  
> **username_2**: Could you reply to the comment?  
> **username_0**: Sorry @BruceBecker (and username_2...) that's almost two years now and I've swapped out all details. No time to go back atm, hope the documentation does help.  
> **username_3**: @BruceBecker that is about the node's health, not that of a service or task  

---

## 0 answers

