Skip to content

Instantly share code, notes, and snippets.

@ponelat
Last active August 5, 2016 15:53
Show Gist options
  • Save ponelat/0db79e98a8ace9a85bf74aa018e063b3 to your computer and use it in GitHub Desktop.
Save ponelat/0db79e98a8ace9a85bf74aa018e063b3 to your computer and use it in GitHub Desktop.
docker clean
#!/bin/sh
# Run with...
# Use the raw github link ( there will be a button on this page)
# curl -sL https://gist.githubusercontent.com/.... | sudo bash
echo ====================================================
docker rm -v $(docker ps -a -q -f status=exited) || echo 'No containers to clean up with status=exited'
echo ====================================================
docker rmi $(docker images -f "dangling=true" -q) || echo 'No images to clean up with dangling=true'
echo ====================================================
docker volume rm $(docker volume ls -qf dangling=true) || echo "No dangling volumes to clean"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment