#!/bin/bash -eu
#
# Call Docker Remote API for all machines in docker-machine.
#
get() {
local node=$1
local path=$2
declare ip=$(docker-machine ip $node)
declare cert_path=$MACHINE_STORAGE_PATH/machines/$node
curl -sk --cert $cert_path/cert.pem --key $cert_path/key.pem \
https://$ip:2376/$path
}
list() {
local path=$1
while read node; do
get $node $path | jq .[] &
done < <(docker-machine ls -q)
wait
}
list containers/json | jq -s .