Created
February 23, 2018 20:26
-
-
Save cambierr/c4de6e84becd01caf6feb7b8ee364a08 to your computer and use it in GitHub Desktop.
This scripts is a temporary workaround for https://github.com/moby/moby/issues/32620
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker node ls --format '{{.ID}}' | xargs docker node inspect --format '{{.Status.Addr}}' | while read node; do | |
echo "Processing node $node" | |
ssh -n $node "docker ps -a --filter 'is-task=true' --format '{{.ID}} {{.Label \"com.docker.stack.namespace\"}}'" | while read container; do | |
id=$(echo $container | cut -d ' ' -f1) | |
stack=$(echo $container | cut -d ' ' -f2) | |
found=$(docker stack ls | grep $stack | wc -l) | |
if [ $found == "0" ]; then | |
echo "no stack $stack found for container $id" | |
ssh -n $node "docker rm -f $id" | |
else | |
echo "found stack $stack for container $id" | |
fi | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment