Skip to content

Instantly share code, notes, and snippets.

@mivano
Forked from bradwilson/docker-clean.ps1
Created February 12, 2018 16:52
Show Gist options
  • Save mivano/88bb6795d681293a2433b6547e277050 to your computer and use it in GitHub Desktop.
Save mivano/88bb6795d681293a2433b6547e277050 to your computer and use it in GitHub Desktop.
Docker Cleanup
(& docker images --all --quiet --filter 'dangling=true') | Foreach-Object {
& docker rmi $_ | out-null
}
(& docker ps --quiet --filter 'status=exited' ) | Foreach-Object {
& docker rm $_ | out-null
}
_images=$(docker images --all --quiet --filter 'dangling=true')
[[ -z ${_images// } ]] || docker rmi $_images
_containers=$(docker ps --quiet --filter 'status=exited')
[[ -z ${_containers// } ]] || docker rm $_containers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment