PB.Docker-Logs.psm1
function Docker-Logs { <# .SYNOPSIS Get Docker container logs .EXAMPLE % docker-logs (host) (container ID or Name) #> [PoshBot.BotCommand( CommandName = 'docker-logs', Aliases = ('dlog', 'docker-logs') )] [cmdletbinding()] param( [parameter(ValueFromRemainingArguments = $true)] [string[]]$Arguments ) $q = $Arguments -split ' ' $env:docker_host = "tcp://$($q[0]):2375" $search = "$($q[1])" if (!$search) { write-error "You must specify a Name or ContainerID`nExample Usage: % docker-logs (host) (Name or ContainerId filter)" } else { $dlog = docker logs $search $dlog | out-file -filepath $PSscriptRoot\$search.json -Force New-PoshBotFileUpload -Path $PSscriptRoot\$search.json -Title "$search.logs" New-PoshBotCardResponse -Type Normal -Title "Example Usage" -Text "% docker-logs (host) (Name or ContainerId filter)" $fields = @{ Host = $q[0] Search = $q[1] } New-PoshBotCardResponse -Type Normal -Fields $fields } } Export-ModuleMember -Function 'Docker-Logs' |