PB.Docker-PS.psm1
function Docker-PS { <# .SYNOPSIS Lists Docker PS on specific Host .EXAMPLE % docker-ps (host) #> [PoshBot.BotCommand( CommandName = 'docker-ps', Aliases = ('dps', 'docker-ps') )] [cmdletbinding()] param( [parameter(ValueFromRemainingArguments = $true)] [string[]]$Arguments ) $q = $Arguments -split ' ' $env:docker_host = "tcp://$($q[0]):2375" $search = "$($q[1])" if (!$search) { $processes = docker ps | ConvertFrom-Docker } else { $processes = docker ps | ConvertFrom-Docker | where-object image -like "*$search*" } New-PoshBotCardResponse -Type Normal -Title "Example Usage" -Text "% docker-ps (host) {Option image filter}" foreach ($process in $processes) { $fields = @{ Host = $q[0] Search = $q[1] Image = $process.Image Name = $process.Names Status = $process.Status Ports = $process.Ports Command = $process.Command ContainerID = $process.ContainerID } New-PoshBotCardResponse -Type Normal -Fields $fields } Export-ModuleMember -Function 'Docker-PS' } |