Skip to content

Instantly share code, notes, and snippets.

@b1zzu
Last active February 1, 2017 19:59
Show Gist options
  • Save b1zzu/d52ab323d9dfb46b9c26e571671300e9 to your computer and use it in GitHub Desktop.
Save b1zzu/d52ab323d9dfb46b9c26e571671300e9 to your computer and use it in GitHub Desktop.
# 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