Last active
February 1, 2017 19:59
-
-
Save b1zzu/d52ab323d9dfb46b9c26e571671300e9 to your computer and use it in GitHub Desktop.
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
# Set the container you want to skip | |
$Skip = "centos","ID" | |
docker ps -a | foreach { | |
$rows = [regex]::Split($_, "\s+"); | |
if ( $rows[1] -notin $Skip ) { | |
docker rm $rows[0] | |
} | |
} | |
# Inline | |
# docker ps -a | foreach { $rows = [regex]::Split($_, "\s+"); if ( $rows[1] -notin "centos","ID" ) { docker rm $rows[0] } } | |
# Clean Images | |
docker images | foreach { $rows = $($_ -split "`t" ); if ( $rows[1] -notin $Skip ) { $rows[0] } } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment