Golden Codes - armanexplorer planet

Practical code snippets for Django, Python, Bash, Git and All!

View on GitHub

how to have ports in brief

docker ps --format 'table {{.Names}}\t{{ $myPorts := (split .Ports ", ")}}\t{{range $pindex, $port := $myPorts}}{{if eq (index (split $port ":") 0) "0.0.0.0"}}{{index (split $port ":") 1}} {{end}}{{end}}'

without type

docker ps --format 'table {{.Names}}\t{{ $myPorts := (split .Ports ", ")}}\t{{range $pindex, $port := $myPorts}}{{if eq (index (split $port ":") 0) "0.0.0.0"}}{{index (split (index (split $port ":") 1 ) "/") 0}} {{end}}{{end}}'

general case

docker ps --format 'table {{.Names}}\t{{.Image}}\t{{.Status}}\t{{.RunningFor}}\t{{ $myPorts := (split .Ports ", ")}}\t{{range $pindex, $port := $myPorts}}{{if eq (index (split $port ":") 0) "0.0.0.0"}}{{index (split (index (split $port ":") 1 ) "/") 0}} {{end}}{{end}}'