Skip to content

Instantly share code, notes, and snippets.

@thbkrkr
Last active June 15, 2017 15:49
Show Gist options
  • Select an option

  • Save thbkrkr/92bb5624b459d2e0d6be87d433ad1a62 to your computer and use it in GitHub Desktop.

Select an option

Save thbkrkr/92bb5624b459d2e0d6be87d433ad1a62 to your computer and use it in GitHub Desktop.
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
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment