From 6eddd62a7384941e7514e24d14012ab41a487654 Mon Sep 17 00:00:00 2001 From: Anton Evangelatov Date: Tue, 23 Jun 2020 11:46:21 +0200 Subject: [PATCH] handle get_host_ip on macos --- composer/Dockerfile | 2 +- composer/composer.sh | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/composer/Dockerfile b/composer/Dockerfile index 2c2bd4e35..c0310c3bc 100644 --- a/composer/Dockerfile +++ b/composer/Dockerfile @@ -26,4 +26,4 @@ COPY requirements.txt ./ RUN pip install -r requirements.txt COPY . . -CMD panel serve --address 0.0.0.0 --port $LISTEN_PORT composer.ipynb \ No newline at end of file +CMD panel serve --address 0.0.0.0 --port $LISTEN_PORT composer.ipynb diff --git a/composer/composer.sh b/composer/composer.sh index c3bb07f22..0d8bc8eb9 100755 --- a/composer/composer.sh +++ b/composer/composer.sh @@ -77,7 +77,14 @@ get_host_ip() { # get interface of default route local net_if=$(netstat -rn | awk '/^0.0.0.0/ {thif=substr($0,74,10); print thif;} /^default.*UG/ {thif=substr($0,65,10); print thif;}') # use ifconfig to get addr of that interface - ifconfig ${net_if} | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1' + detected_host_ip=`ifconfig ${net_if} | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1'` + + if [ -z "$detected_host_ip" ] + then + detected_host_ip="host.docker.internal" + fi + + echo $detected_host_ip } # run cleanup on exit