./share/scripts/ip in docker-utils-0.1.34 vs ./share/scripts/ip in docker-utils-0.1.35

- old
+ new

@@ -1,3 +1,28 @@ -#!/bin/bash +#!/bin/sh -command docker inspect --format '{{.NetworkSettings.IPAddress}}' "$1" +mode="once" +if [ "$1" = "-w" ]; then + mode="wait"; shift +fi + +container_name="$1"; shift + +container_ip_addr="" + +if [ "${mode}" = "wait" ]; then + while :; do + container_ip_addr=$(command docker inspect --format '{{.NetworkSettings.IPAddress}}' "${container_name}" 2>/dev/null) + if [ -n "${container_ip_addr}" ]; then + break + fi + sleep 0.1 + done +else + container_ip_addr=$(command docker inspect --format '{{.NetworkSettings.IPAddress}}' "${container_name}" 2>/dev/null) +fi + +if [ -n "${container_ip_addr}" ]; then + echo "${container_ip_addr}" +else + exit 1 +fi