Forked from eduardocardoso/gist:82a629882ddb02ab3677
Last active
October 13, 2017 00:30
-
-
Save stevenschlansker/51c319cdc7cd2764ce48 to your computer and use it in GitHub Desktop.
Revisions
-
stevenschlansker revised this gist
May 27, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ set -o errexit echo "Removing exited docker containers..." docker ps -a -f status=exited -q | xargs -r docker rm -v echo "Removing untagged images..." docker images --no-trunc | grep "<none>" | awk '{print $3}' | xargs -r docker rmi -
stevenschlansker revised this gist
May 27, 2015 . 1 changed file with 10 additions and 7 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,14 +1,17 @@ #!/bin/bash # Shamelessly stolen from https://gist.github.com/eduardocardoso/82a629882ddb02ab3677 set -o errexit echo "Removing exited docker containers..." $(docker ps -a -f status=exited -q) | xargs -r docker rm -v echo "Removing untagged images..." docker images --no-trunc | grep "<none>" | awk '{print $3}' | xargs -r docker rmi echo "Removing unused docker images" images=($(docker images | tail -n +2 | awk '{print $1":"$2}')) containers=($(docker ps -a | tail -n +2 | awk '{print $2}')) containers_reg=" ${containers[*]} " remove=() @@ -21,5 +24,5 @@ done remove_images=" ${remove[*]} " echo ${remove_images} | xargs -r docker rmi echo "Done" -
eduardocardoso revised this gist
Apr 9, 2015 . 1 changed file with 18 additions and 10 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,17 +1,25 @@ #! /bin/bash echo "Removing exited docker containers..." docker rm -v $(docker ps -a -f status=exited -q) echo "Removing untagged images..." docker rmi $(docker images --no-trunc | grep "<none>" | awk '{print $3}') echo "Removing unused docker images" images=($(docker images | awk '{print $1":"$2}')) containers=($(docker ps -a | awk '{print $2}')) containers_reg=" ${containers[*]} " remove=() for item in ${images[@]}; do if [[ ! $containers_reg =~ " $item " ]]; then remove+=($item) fi done remove_images=" ${remove[*]} " docker rmi ${remove_images} echo "Done" -
eduardocardoso revised this gist
Apr 2, 2015 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -8,9 +8,9 @@ echo "Cleaning unused docker images" list1=($(docker images | awk '{print $1":"$2}')) list2=($(docker ps -a | awk '{print $2}')) l2=" ${list2[*]} " for item in ${list1[@]}; do if [[ ! $l2 =~ " $item " ]] ; then docker rmi $item > /dev/null 2> /dev/null 3> /dev/null fi done -
eduardocardoso created this gist
Apr 2, 2015 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ #! /bin/bash echo "Cleaning exited docker containers" docker rm -v $(docker ps -a -f status=exited -q) > /dev/null echo "Done" echo "Cleaning unused docker images" list1=($(docker images | awk '{print $1":"$2}')) list2=($(docker ps -a | awk '{print $2}')) l2=" ${list2[*]} " # add framing blanks for item in ${list1[@]}; do if [[ ! $l2 =~ " $item " ]] ; then # use $item as regexp docker rmi $item > /dev/null 2> /dev/null 3> /dev/null fi done echo "Done"