Created
February 25, 2019 17:02
-
-
Save hartsock/d349921c4823a4fedec0a8d94a41da19 to your computer and use it in GitHub Desktop.
Docker Swarm - Prune all Stopped containers on all Nodes in swarm
This file contains hidden or 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
for NODE in $(docker node ls --format '{{.Hostname}}'); do | |
IP_ADDR="$(docker node inspect --format '{{.Status.Addr}}' "${NODE}")"; | |
echo -e "${NODE} - $(docker node inspect --format '{{.Status.Addr}}' "${NODE}")"; | |
# Presumes your manager node can SSH into all worker nodes | |
ssh ${IP_ADDR} docker container prune -f | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment