Skip to content

Instantly share code, notes, and snippets.

@sxiii
Created October 5, 2020 05:35
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save sxiii/4f60940d257c31ca0ff071c1a015eab2 to your computer and use it in GitHub Desktop.
Save sxiii/4f60940d257c31ca0ff071c1a015eab2 to your computer and use it in GitHub Desktop.
Docker Swarm - Remove all Down nodes automatically
#!/bin/bash
# Requirements: linux, docker, grep, awk
# This script removes all "Down" (off) nodes from Docker Swarm
# Useful to clean stuff from time to time, if you have auto-joining nodes for example
sudo docker node rm $(sudo docker node ls | grep Down | awk -F" " '{ print $1 }')
@Winfle
Copy link

Winfle commented Feb 19, 2023

Cheers!

@CaptainYarb
Copy link

This is epic. Thanks for this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment