handle get_host_ip on macos

This commit is contained in:
Anton Evangelatov 2020-06-23 11:46:21 +02:00 committed by Yusef Napora
parent 306efa66c7
commit 6eddd62a73
2 changed files with 9 additions and 2 deletions

View File

@ -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
CMD panel serve --address 0.0.0.0 --port $LISTEN_PORT composer.ipynb

View File

@ -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