function inst_id2port() { echo $((41000+${1}-1)) } function dnet_container_name() { echo dnet-$1-$2 } function start_consul() { stop_consul docker run -d \ --name=pr_consul \ -p 8500:8500 \ -p 8300-8302:8300-8302/tcp \ -p 8300-8302:8300-8302/udp \ -h consul \ progrium/consul -server -bootstrap sleep 2 } function stop_consul() { echo "consul started" docker stop pr_consul || true # You cannot destroy a container in Circle CI. So do not attempt destroy in circleci if [ -z "$CIRCLECI" ]; then docker rm -f pr_consul || true fi } function start_dnet() { stop_dnet $1 $2 name=$(dnet_container_name $1 $2) if [ -z "$3" ] then hport=$((41000+${1}-1)) cport=2385 hopt="" else hport=$3 cport=$3 hopt="-H tcp://0.0.0.0:${cport}" fi bridge_ip=$(docker inspect --format '{{.NetworkSettings.Gateway}}' pr_consul) mkdir -p /tmp/dnet/${name} tomlfile="/tmp/dnet/${name}/libnetwork.toml" cat > ${tomlfile} <