Created
February 22, 2026 21:05
-
-
Save MMTE/9227ec90981dff4037156120b164a426 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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