Fix DOCKER_HOST_IP handling for multihomed machines. (#9225)

By picking one. Otherwise, when a machine has multiple IP addresses, DOCKER_HOST_IP
would have a newline in the middle, causing havoc in configuration files.
This commit is contained in:
Gian Merlino 2020-01-21 09:01:19 -08:00 committed by Fangjin Yang
parent 8011211a0c
commit f511af1306
1 changed files with 1 additions and 1 deletions

View File

@ -18,7 +18,7 @@
DOCKER_HOST_IP="$(host "$(hostname)" | perl -nle '/has address (.*)/ && print $1')"
if [ -z "$DOCKER_HOST_IP" ]; then
# Mac specific way to get host ip
DOCKER_HOST_IP="$(dscacheutil -q host -a name "$(HOSTNAME)" | perl -nle '/ip_address: (.*)/ && print $1')"
DOCKER_HOST_IP="$(dscacheutil -q host -a name "$(HOSTNAME)" | perl -nle '/ip_address: (.*)/ && print $1' | tail -n1)"
fi
if [ -z "$DOCKER_HOST_IP" ]; then