Skip to content

Instantly share code, notes, and snippets.

@MMTE
Created February 22, 2026 21:05
Show Gist options
  • Select an option

  • Save MMTE/9227ec90981dff4037156120b164a426 to your computer and use it in GitHub Desktop.

Select an option

Save MMTE/9227ec90981dff4037156120b164a426 to your computer and use it in GitHub Desktop.
sudo tee /usr/local/bin/dps <<'EOF'
#!/bin/bash
# Define colors for the "Status" logic
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
echo -e "${YELLOW}CONTAINER STATUS PORTS IMAGE${NC}"
echo "-----------------------------------------------------------------------------------"
docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}\t{{.Image}}" | sed 1d | \
awk -F'\t' '{
status_color="\033[0;32m"; # Default Green
if ($2 ~ /Exited/ || $2 ~ /Restarting/) status_color="\033[0;31m";
if ($2 ~ /unhealthy/) status_color="\033[1;33m";
printf "%-18s %-15s %-30s %-20s\n", $1, status_color $2 "\033[0m", $3, $4
}'
EOF
sudo chmod +x /usr/local/bin/dps
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment