clean_env.sh 803 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/usr/bin/env bash
  2. # This script will remove all containers and hyperledger related images
  3. # Detecting whether can import the header file to render colorful cli output
  4. # Need add choice option
  5. if [ -f ./header.sh ]; then
  6. source ./header.sh
  7. elif [ -f scripts/header.sh ]; then
  8. source scripts/header.sh
  9. else
  10. echo_r() {
  11. echo "$@"
  12. }
  13. echo_g() {
  14. echo "$@"
  15. }
  16. echo_b() {
  17. echo "$@"
  18. }
  19. fi
  20. echo_b "Clean up all containers..."
  21. docker rm -f `docker ps -qa`
  22. echo_b "Clean up all chaincode images..."
  23. docker rmi -f $(docker images |grep 'dev-peer'|awk '{print $3}')
  24. echo_b "Clean up all hyperledger related images..."
  25. docker rmi -f $(docker images |grep 'hyperledger'|awk '{print $3}')
  26. echo_b "Clean up dangling images..."
  27. docker rmi $(docker images -q -f dangling=true)
  28. echo_g "Env cleanup done!"