Skip to content
This repository was archived by the owner on Apr 3, 2025. It is now read-only.

Commit ab8065c

Browse files
tomwganemtonivdv
authored andcommitted
fix: for vsphere-driver, determine ip to use from routing table (#85)
1 parent d40dfa0 commit ab8065c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

docker-machine-nfs.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,10 +311,12 @@ lookupMandatoryProperties ()
311311
fi
312312

313313
if [ "$prop_machine_driver" = "vmwarevsphere" ]; then
314-
prop_nfshost_ip=${prop_use_ip:-}
314+
# Checks the routing table to find the ip address that your machine will use to connect to the docker-machine
315+
machine_ip=$(netstat -rn -f inet | awk -v pattern="^$(route get ${prop_machine_ip} | grep gateway | awk '{print $2}')[^\/]" '$0 ~ pattern {print $2}')
316+
prop_nfshost_ip=${prop_use_ip:-${machine_ip}}
315317

316318
if [ "" = "${prop_nfshost_ip}" ]; then
317-
echoError "Need to explictly set ip to use with -p|--ip!"; exit 1
319+
echoError "Could not find a route to the docker-machine!"; exit 1
318320
fi
319321

320322
echoSuccess "OK"

0 commit comments

Comments
 (0)