Skip to content

Instantly share code, notes, and snippets.

@ipedrazas
Created September 18, 2014 22:13
Show Gist options
  • Save ipedrazas/2c93f6e74737d1f8a791 to your computer and use it in GitHub Desktop.
Save ipedrazas/2c93f6e74737d1f8a791 to your computer and use it in GitHub Desktop.
List Docker Container Names and IPs
function drips(){
docker ps -q | xargs -n 1 docker inspect --format '{{ .NetworkSettings.IPAddress }} {{ .Name }}' | sed 's/ \// /'
}
@audioscavenger
Copy link

my one liner solution works like @zeroows but adds CR when containers have multiple networks
docker container ls -q | xargs -r docker container inspect | jq -r '.[]|"\(.NetworkSettings.Networks[].IPAddress|select(length > 0) // "# no ip address:") \(.Name|sub("^/"; "")|sub("_1$"; "")|sub("-1$"; ""))"'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment