docker-compose-files/hyperledger_fabric/v1.0.5/scripts/clean_env.sh

35 lines
803 B
Bash
Raw Normal View History

#!/usr/bin/env bash
# This script will remove all containers and hyperledger related images
# Detecting whether can import the header file to render colorful cli output
# Need add choice option
if [ -f ./header.sh ]; then
source ./header.sh
elif [ -f scripts/header.sh ]; then
source scripts/header.sh
else
2017-12-19 14:40:39 +08:00
echo_r() {
echo "$@"
}
echo_g() {
echo "$@"
}
echo_b() {
echo "$@"
}
fi
echo_b "Clean up all containers..."
docker rm -f `docker ps -qa`
2017-10-06 14:47:32 +08:00
echo_b "Clean up all chaincode images..."
docker rmi -f $(docker images |grep 'dev-peer'|awk '{print $3}')
echo_b "Clean up all hyperledger related images..."
2017-10-06 14:47:32 +08:00
docker rmi -f $(docker images |grep 'hyperledger'|awk '{print $3}')
echo_b "Clean up dangling images..."
docker rmi $(docker images -q -f dangling=true)
echo_g "Env cleanup done!"