一千萬個為什麽

搜索

Docker Swarm服務健康檢查?



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.

但是,我想知道Docker服務的狀態,特別是在docker service ls或ps命令中。如何在Docker Swarm部署中檢查服務的健康狀態(即容器的一個或多個副本)?

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

在此先感謝您的任何建議。

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

轉載註明原文: Docker Swarm服務健康檢查?

一共有 0 個回答: