Skip to content

Instantly share code, notes, and snippets.

@bradwilson
Created February 7, 2018 00:36
Show Gist options
  • Save bradwilson/67bddf8a3e5d45bfe3d4c0c5bab4b954 to your computer and use it in GitHub Desktop.
Save bradwilson/67bddf8a3e5d45bfe3d4c0c5bab4b954 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