From aad33caf381bf79087c01c3245d400813f3a542b Mon Sep 17 00:00:00 2001 From: vandepol Date: Thu, 21 Dec 2017 14:13:29 -0500 Subject: [PATCH] dynamically determine host IP When trying to expose a post running on another docker container requires the IP address of the host instead of localhost. Dynamically determined the host IP address and used that for the port forwarding --- run.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/run.sh b/run.sh index 5bc5a81..2fc20e4 100644 --- a/run.sh +++ b/run.sh @@ -65,9 +65,10 @@ if [[ -n "${PUBLIC_HOST_ADDR}" && -n "${PUBLIC_HOST_PORT}" ]]; then echo "====REMOTE FINGERPRINT====" cat ${KNOWN_HOSTS} echo "====REMOTE FINGERPRINT====" - + localhostIP=$(/sbin/ip route|awk '/default/ { print $3 }') + echo "hosts IP (according to /sbin/ip route) is: ${localhostIP}" echo "=> Setting up the reverse ssh tunnel" - sshpass -p ${ROOT_PASS} autossh -M 0 -NgR 1080:localhost:${PROXY_PORT} root@${PUBLIC_HOST_ADDR} -p ${PUBLIC_HOST_PORT} + sshpass -p ${ROOT_PASS} autossh -M 0 -NgR 1080:${localhostIP}:${PROXY_PORT} root@${PUBLIC_HOST_ADDR} -p ${PUBLIC_HOST_PORT} else echo "=> Running in public host mode" if [ ! -f /.root_pw_set ]; then