Skip to content

Instantly share code, notes, and snippets.

@labboy0276
Last active October 5, 2023 15:40
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save labboy0276/4406db072f9ed3bf3641f57c1d902027 to your computer and use it in GitHub Desktop.
Save labboy0276/4406db072f9ed3bf3641f57c1d902027 to your computer and use it in GitHub Desktop.
Purge all Docker Containers & Lando Cache
#!/bin/bash
echo 'Stopping Containers'
# Stop all containers
containers=`docker ps -a -q`
if [ -n "$containers" ] ; then
docker stop $containers
fi
echo 'Deleting Containers'
# Delete all containers
containers=`docker ps -a -q`
if [ -n "$containers" ]; then
docker rm -f -v $containers
fi
echo 'Deleting Images'
# Delete all images
images=`docker images -q -a`
if [ -n "$images" ]; then
docker rmi -f $images
fi
echo 'Pruning Network'
docker network prune -f
echo 'Purging Lando Cache'
rm -rf ~/.lando/cache
@labboy0276
Copy link
Author

fancy

@gitressa
Copy link

gitressa commented Mar 9, 2022

Thanks for sharing @generalredneck, that does the job perfectly, and everything gets cleaned up nicely.

I was just about to suggest adding it to the documentation, but when I looked, I see you beat me to it @labboy0276 :)
https://docs.lando.dev/help/purging-containers.html

PS. "behvaior"

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