-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathdps.ps1
More file actions
20 lines (17 loc) · 787 Bytes
/
dps.ps1
File metadata and controls
20 lines (17 loc) · 787 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Format, colorize docker ps output
# Define a fixed width for the STATUS column
$statusWidth = 30
# Capture the Docker output into a variable
$dockerOutput = docker ps -f status=running -f status=exited --format "{{.Names}}`t{{.Status}}`t{{.Ports}}"
# Print header with colors
Write-Host ("NAME".PadRight(20) + "STATUS".PadRight($statusWidth) + "PORTS") -ForegroundColor Cyan -NoNewline
Write-Host ""
# Split the output into lines and loop over them
$dockerOutput -split '\r?\n' | ForEach-Object {
if ($_ -ne "") {
$fields = $_ -split "`t"
Write-Host ($fields[0].PadRight(20)) -NoNewline -ForegroundColor Yellow
Write-Host ($fields[1].PadRight($statusWidth)) -NoNewline -ForegroundColor Green
Write-Host ($fields[2]) -ForegroundColor Blue
}
}