Skip to content

Instantly share code, notes, and snippets.

@TheToddLuci0
Created February 11, 2020 15:29
Show Gist options
  • Save TheToddLuci0/fb31f5532fa1a7cb980be4a8ca06f214 to your computer and use it in GitHub Desktop.
Save TheToddLuci0/fb31f5532fa1a7cb980be4a8ca06f214 to your computer and use it in GitHub Desktop.
Helper script to make killing background docker containers easier
<#
.SYNOPSIS
Script to kill docker containers running in the background
.PARAMETER target
The line number of `docker ps` output that represents the container to kill
.NOTES
Author: @TheToddLuci0
#>
$s=docker ps
$kill_target=1
if($Args[0]){
$kill_target=$Args[0]
}
$s.split([Environment]::NewLine)[$kill_target].split()[-1] | %{&"docker" kill $_}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment