# Start DB
echo "---> Starting Mongo"
DB_ID=$(docker run -d -P docker-registry.intranet/mongo:2.4)
DB_PORT=$(docker inspect --format '{{range $i, $e := .NetworkSettings.Ports}}{{if $e}}{{$p := index $e 0}}{{$p.HostPort}}{{end}}{{end}}' $DB_ID)
echo "Found Mongo at port $DB_PORT"
if [[ -n $DOCKER_HOST ]]; then
DB_IP=$(echo $DOCKER_HOST|sed -e 's|tcp://||' -e 's|:[0-9]\+||')
else
DB_IP=localhost
fi
echo "Waiting for Mongo at $DB_IP:$DB_PORT to begin listening"
until nc -z $DB_IP $DB_PORT; do
sleep 0.5
done
echo "Done!"