27 lines
1,022 B
Bash
Executable file
27 lines
1,022 B
Bash
Executable file
#!/bin/bash
|
|
|
|
# Optional base hostname (e.g., monitor.local)
|
|
BASE_HOST="${NGINX_HOST:-localhost}"
|
|
|
|
printf "%-20s | %-15s | %-25s | %-40s\n" "Service" "IP Address" "Port Bindings" "URL"
|
|
printf "%s\n" "---------------------------------------------------------------------------------------------------------------"
|
|
|
|
for container in $(docker ps --format '{{.Names}}'); do
|
|
ip=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$container")
|
|
|
|
ports=$(docker inspect -f '{{range $p, $conf := .NetworkSettings.Ports}}{{if $conf}}{{$conf | json}}{{end}}{{end}}' "$container" \
|
|
| jq -r '.[] | "\(.HostPort)"' 2>/dev/null | paste -sd "," -)
|
|
|
|
if [ -z "$ports" ]; then
|
|
ports="(none)"
|
|
url="(none)"
|
|
else
|
|
# Just use the first port for URL
|
|
first_port=$(echo "$ports" | cut -d',' -f1)
|
|
scheme="http"
|
|
[ "$first_port" = "443" ] && scheme="https"
|
|
url="$scheme://$BASE_HOST:$first_port"
|
|
fi
|
|
|
|
printf "%-20s | %-15s | %-25s | %-40s\n" "$container" "$ip" "$ports" "$url"
|
|
done |