Skip to content

Instantly share code, notes, and snippets.

@jrgcubano
Forked from bradwilson/docker-clean.ps1
Created February 7, 2018 14:18
Show Gist options
  • Save jrgcubano/92ed975fb41efede2ccd1fb5a3848bc9 to your computer and use it in GitHub Desktop.
Save jrgcubano/92ed975fb41efede2ccd1fb5a3848bc9 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