Skip to content

Instantly share code, notes, and snippets.

@jpaulolxm
Forked from sxiii/remove.sh
Last active February 19, 2025 01:54
Show Gist options
  • Select an option

  • Save jpaulolxm/831d97ac29817942afdc11f42105184e to your computer and use it in GitHub Desktop.

Select an option

Save jpaulolxm/831d97ac29817942afdc11f42105184e 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 }')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment