thbkrkr
6/15/2017 - 3:15 PM

List IP of all containers of a Swarm cluster

List IP of all containers of a Swarm cluster

# list_ips kaastor faas_functions
list_ips() {
  declare filterName=$1 network=$2
  for m in $(docker-machine ls -q); do
    echo -- $m
    eval $(set_docker_env $m)
    for ID in $(docker ps --filter=name=$filterName --format={{.ID}}); do
      docker inspect $ID | jq -c '.[] | {
        name:.Name,
        ip:.NetworkSettings.Networks.'$network'.IPAddress
      }'
    done
  done
}