The very personal dotfiles of Levi Olson.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
699 B

6 years ago
  1. #!/bin/bash
  2. ##########################################
  3. # docker-cleanup-everything
  4. # ------------
  5. # Based on the amazing work of Jess Frazelle
  6. #
  7. # Dependencies: docker
  8. #
  9. # :author: Levi Olson
  10. # :date: 31 Jan 2018
  11. # :version: 0.0.1
  12. ##########################################
  13. cleanup() {
  14. local containers
  15. mapfile -t containers < <(docker ps -aq 2>/dev/null)
  16. docker rm "${containers[@]}" 2>/dev/null
  17. local volumes
  18. mapfile -t volumes < <(docker ps --filter status=exited -q 2>/dev/null)
  19. docker rm -v "${volumes[@]}" 2>/dev/null
  20. local images
  21. mapfile -t images < <(docker images --filter dangling=true -q 2>/dev/null)
  22. docker rmi "${images[@]}" 2>/dev/null
  23. }
  24. cleanup