-
-
Save alcapone1933/1b0aa9b06fd05d623d892f841f940b8d to your computer and use it in GitHub Desktop.
Revisions
-
Brian Clements revised this gist
Nov 28, 2014 . 1 changed file with 4 additions and 4 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 @@ -13,19 +13,19 @@ if [ "$1" == "--reset" ]; then # Remove all containers regardless of state docker rm -vf $(docker ps -a -q) 2>/dev/null || echo "No more containers to remove." elif [ "$1" == "--purge" ]; then # Attempt to remove running containers that are using the images we're trying to purge first. (docker rm -vf $(docker ps -a | grep "$2/\|/$2 \| $2 \|:$2\|$2-\|$2:\|$2_" | awk '{print $1}') 2>/dev/null || echo "No containers using the \"$2\" image, continuing purge.") &&\ # Remove all images matching arg given after "--purge" docker rmi $(docker images | grep "$2/\|/$2 \| $2 \|$2 \|$2-\|$2_" | awk '{print $3}') 2>/dev/null || echo "No images matching \"$2\" to purge." else # This alternate only removes "stopped" containers docker rm -vf $(docker ps -a | grep "Exited" | awk '{print $1}') 2>/dev/null || echo "No stopped containers to remove." fi if [ "$1" == "--nuclear" ]; then docker rm -vf $(docker ps -a -q) 2>/dev/null || echo "No more containers to remove." docker rmi $(docker images -q) 2>/dev/null || echo "No more images to remove." else # Always remove untagged images -
Brian Clements revised this gist
Oct 9, 2014 . 1 changed file with 13 additions and 6 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,21 +8,28 @@ # remove containers|images|tags matching {repository|image|repository\image|tag|image:tag} # pattern and untagged images # $ dkcleanup --purge {image} # everything # $ dkcleanup --nuclear if [ "$1" == "--reset" ]; then # Remove all containers regardless of state docker rm -f $(docker ps -a -q) 2>/dev/null || echo "No more containers to remove." elif [ "$1" == "--purge" ]; then # Attempt to remove running containers that are using the images we're trying to purge first. (docker rm -f $(docker ps -a | grep "$2/\|/$2 \| $2 \|:$2\|$2-\|$2:\|$2_" | awk '{print $1}') 2>/dev/null || echo "No containers using the \"$2\" image, continuing purge.") &&\ # Remove all images matching arg given after "--purge" docker rmi $(docker images | grep "$2/\|/$2 \| $2 \|$2 \|$2-\|$2_" | awk '{print $3}') 2>/dev/null || echo "No images matching \"$2\" to purge." else # This alternate only removes "stopped" containers docker rm -f $(docker ps -a | grep "Exited" | awk '{print $1}') 2>/dev/null || echo "No stopped containers to remove." fi if [ "$1" == "--nuclear" ]; then docker rm -f $(docker ps -a -q) 2>/dev/null || echo "No more containers to remove." docker rmi $(docker images -q) 2>/dev/null || echo "No more images to remove." else # Always remove untagged images docker rmi $(docker images | grep "<none>" | awk '{print $3}') 2>/dev/null || echo "No untagged images to delete." fi exit 0 -
Brian Clements revised this gist
Jun 7, 2014 . 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 @@ -14,9 +14,9 @@ if [ "$1" == "--reset" ]; then sudo docker rm -f $(sudo docker ps -a -q) 2>/dev/null || echo "No more containers to remove." elif [ "$1" == "--purge" ]; then # Attempt to remove running containers that are using the images we're trying to purge first. (sudo docker rm -f $(sudo docker ps -a | grep "$2/\|/$2 \| $2 \|:$2\|$2-\|$2:" | awk '{print $1}') 2>/dev/null || echo "No containers using the \"$2\" image, continuing purge.") &&\ # Remove all images matching arg given after "--purge" sudo docker rmi $(sudo docker images | grep "$2/\|/$2 \| $2 \|$2 \|$2-" | awk '{print $3}') 2>/dev/null || echo "No images matching \"$2\" to purge." else # This alternate only removes "stopped" containers sudo docker rm -f $(sudo docker ps -a | grep "Exited" | awk '{print $1}') 2>/dev/null || echo "No stopped containers to remove." -
Brian Clements revised this gist
Jun 7, 2014 . 1 changed file with 11 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,21 +1,25 @@ #!/bin/bash # options: # remove stopped containers and untagged images # $ dkcleanup # remove all stopped|running containers and untagged images # $ dkcleanup --reset # remove containers|images|tags matching {repository|image|repository\image|tag|image:tag} # pattern and untagged images # $ dkcleanup --purge {image} if [ "$1" == "--reset" ]; then # Remove all containers regardless of state sudo docker rm -f $(sudo docker ps -a -q) 2>/dev/null || echo "No more containers to remove." elif [ "$1" == "--purge" ]; then # Attempt to remove running containers that are using the images we're trying to purge first. sudo docker rm -f $(sudo docker ps -a | grep "$2/\|/$2 \| $2 \|:$2" | awk '{print $1}') 2>/dev/null || echo "No containers using the \"$2\", continuing purge." # Remove all images matching arg given after "--purge" sudo docker rmi $(sudo docker images | grep "$2/\|/$2 \| $2 \|$2 " | awk '{print $3}') 2>/dev/null || echo "No images matching \"$2\" to purge." else # This alternate only removes "stopped" containers sudo docker rm -f $(sudo docker ps -a | grep "Exited" | awk '{print $1}') 2>/dev/null || echo "No stopped containers to remove." fi # Always remove untagged images -
Brian Clements revised this gist
Jun 6, 2014 . 1 changed file with 10 additions and 3 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,24 @@ #!/bin/bash # usage: # $ dkcleanup # removes stopped containers and untagged images # $ dkcleanup --reset # removes all stopped/running containers and untagged images # $ dkcleanup --purge {image} # removes containers and images matching {image} pattern and untagged images if [ "$1" == "--reset" ]; then # Remove all containers regardless of state sudo docker rm -f $(sudo docker ps -a -q) 2>/dev/null || echo "No more containers to remove." elif [ "$1" == "--purge" ]; then # Attempt to remove running containers that are using the images we're trying to purge first. sudo docker rm -f $(sudo docker ps -a | grep "$2" | awk '{print $1}') 2>/dev/null || echo "No containers using the \"$2\", continuing purge." # Remove all images matching arg given after "--purge" sudo docker rmi $(sudo docker images | grep "$2" | awk '{print $3}') 2>/dev/null || echo "No images matching \"$2\" to purge." else # This alternate only removes "stopped" containers sudo docker rm -f $(sudo docker ps -a | grep "Exit" | awk '{print $1}') 2>/dev/null || echo "No stopped containers to remove." fi # Always remove untagged images sudo docker rmi $(sudo docker images | grep "<none>" | awk '{print $3}') 2>/dev/null || echo "No untagged images to delete." exit 0 -
Brian Clements revised this gist
Jun 6, 2014 . 1 changed file with 3 additions and 0 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 @@ -3,6 +3,9 @@ if [ "$1" == "--reset" ]; then # Remove all containers regardless of state sudo docker rm -f $(sudo docker ps -a -q) 2>/dev/null || echo "No containers to remove." elif [ "$1" == "--purge" ]; then # Remove all images matching arg given after "--purge" sudo docker rmi $(sudo docker images | grep "$2" | awk '{print $3}') 2>/dev/null || echo "No images matching \"$2\"." else # This alternate only removes "stopped" containers sudo docker rm -f $(sudo docker ps -a | grep "Exit" | awk '{print $1}') 2>/dev/null || echo "No stopped containers to remove." -
Brian Clements revised this gist
May 15, 2014 . 1 changed file with 9 additions 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 @@ -1,6 +1,14 @@ #!/bin/bash if [ "$1" == "--reset" ]; then # Remove all containers regardless of state sudo docker rm -f $(sudo docker ps -a -q) 2>/dev/null || echo "No containers to remove." else # This alternate only removes "stopped" containers sudo docker rm -f $(sudo docker ps -a | grep "Exit" | awk '{print $1}') 2>/dev/null || echo "No stopped containers to remove." fi # Always remove untagged images sudo docker rmi $(sudo docker images | grep "<none>" | awk '{print $3}') 2>/dev/null || echo "No images to delete." exit 0 -
Brian Clements created this gist
May 12, 2014 .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,6 @@ #!/bin/bash sudo docker rm -f $(sudo docker ps -a -q) 2>/dev/null || echo "No containers to delete." sudo docker rmi $(sudo docker images | grep "<none>" | awk '{print $3}') 2>/dev/null || echo "No images to delete." exit 0