Skip to content

Instantly share code, notes, and snippets.

@jacek-marchwicki
Created April 11, 2018 13:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jacek-marchwicki/447596428acacd752ea76d4076d50650 to your computer and use it in GitHub Desktop.
Save jacek-marchwicki/447596428acacd752ea76d4076d50650 to your computer and use it in GitHub Desktop.
Clean old images
#!/bin/bash -e
echo "WARNING"
echo "All docker files that are currenlty not runned will be removed!"
echo "Press enter to continue, or ctrl+c"
read
echo "Removing stopped images"
docker ps -a -q -f status=exited | xargs --no-run-if-empty docker rm || echo "Oooopps..."
echo "Removing not used images"
docker images -q | xargs --no-run-if-empty docker rmi || echo "Oooopps..."
echo "Removing orphaned volumes"
docker volume ls -qf dangling=true | xargs -r docker volume rm || echo "Oooopps..."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment