Last active
August 29, 2015 13:57
-
-
Save flaudisio/9748644 to your computer and use it in GitHub Desktop.
Funções (muito) básicas para administração do Docker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Docker | |
# | |
wipe_containers() | |
{ | |
[[ "$1" ]] || return 2 | |
local opts | |
[[ "$1" == "--rm" ]] && opts="-a" | |
for c in $( docker ps -q $opts ) ; do | |
docker "${1/--/}" "$c" | |
done | |
} | |
kill_all_containers() { wipe_containers --kill ; } | |
stop_all_containers() { wipe_containers --stop ; } | |
rm_all_containers() { wipe_containers --rm ; } | |
rm_none_images() | |
{ | |
for i in $( docker images | egrep '^<none>' | awk '{ print $3 }' ) ; do | |
echo "--> Removendo $i" | |
docker rmi "$i" | |
done | |
} | |
docker_cleanup() | |
{ | |
for cmd in {kill,rm}_all_containers rm_none_images ; do | |
echo "-> $cmd" | |
"$cmd" || return 1 | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment