#!/bin/bash MYIP=$(ip -4 addr show eth0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}') for i in $(docker ps --format '{{.Names}}'); do docker port $i | grep -oP '(?<=0:)[1-9].*' | while read -r MYPORT; do if [[ -n $MYPORT ]]; then MYRESPONSE=$(curl -Is --max-time 0.5 $MYIP:$MYPORT | head -1 | grep -oP '[0-9][0-9][0-9]') pat="2|3" if [[ ${MYRESPONSE:0:1} =~ $pat ]]; then printf "| %20s | %-20s | %-10s | \n" "$i" "$MYIP:$MYPORT" "$MYRESPONSE" fi fi done done
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter