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

Commit 48c9167

Browse files
Tom Ganemtonivdv
authored andcommitted
docker-machine can connect to host machine via explicit address (#84)
1 parent eebf3d4 commit 48c9167

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ brew install docker-machine-nfs
3232
* Virtualbox
3333
* Paralells
3434
* VMware Fusion
35+
* VMware Vsphere
3536
* xhyve
3637

3738
## Usage
@@ -76,6 +77,10 @@ Examples:
7677
7778
> Configure the /User folder with NFS and specific mount options.
7879
80+
$ docker-machine-nfs test --ip 192.168.1.12
81+
82+
> docker-machine will connect to your host machine via this address
83+
7984
```
8085
8186
## Credits

docker-machine-nfs.sh

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ Options:
5959
-s, --shared-folder,... Folder to share (default to /Users)
6060
-m, --mount-opts NFS mount options (default to 'noacl,async')
6161
-i, --use-ip-range Changes the nfs export ip to a range (e.g. -network 192.168.99.100 becomes -network 192.168.99)
62+
-p, --ip Configures the docker-machine to connect to your host machine via a specific ip address
6263
6364
Examples:
6465
@@ -77,6 +78,10 @@ Examples:
7778
$ docker-machine-nfs test --mount-opts="noacl,async,nolock,vers=3,udp,noatime,actimeo=1"
7879
7980
> Configure the /User folder with NFS and specific mount options.
81+
82+
$ docker-machine-nfs test --ip 192.168.1.12
83+
84+
> docker-machine will connect to your host machine via this address
8085
EOF
8186
exit 0
8287
}
@@ -132,6 +137,7 @@ setPropDefaults()
132137
prop_mount_options="noacl,async"
133138
prop_force_configuration_nfs=false
134139
prop_use_ip_range=false
140+
prop_use_ip=
135141
}
136142

137143
# @info: Parses and validates the CLI arguments
@@ -173,6 +179,10 @@ parseCli()
173179
prop_use_ip_range=true
174180
;;
175181

182+
-p=*|--ip=*)
183+
prop_use_ip="${i#*=}"
184+
;;
185+
176186
*)
177187
echoError "Unknown argument '$i' given"
178188
echo #EMPTY
@@ -253,7 +263,7 @@ lookupMandatoryProperties ()
253263

254264
if [ "$prop_machine_driver" = "vmwarefusion" ]; then
255265
prop_network_id="Shared"
256-
prop_nfshost_ip=$(ifconfig -m `route get 8.8.8.8 | awk '{if ($1 ~ /interface:/){print $2}}'` | awk 'sub(/inet /,""){print $1}')
266+
prop_nfshost_ip=${prop_use_ip:-"$(ifconfig -m `route get 8.8.8.8 | awk '{if ($1 ~ /interface:/){print $2}}'` | awk 'sub(/inet /,""){print $1}')"}
257267
prop_machine_ip=$prop_nfshost_ip
258268
if [ "" = "${prop_nfshost_ip}" ]; then
259269
echoError "Could not find the vmware fusion net IP!"; exit 1
@@ -279,7 +289,7 @@ lookupMandatoryProperties ()
279289

280290
if [ "$prop_machine_driver" = "xhyve" ]; then
281291
prop_network_id="Shared"
282-
prop_nfshost_ip=$(ifconfig -m `route get $prop_machine_ip | awk '{if ($1 ~ /interface:/){print $2}}'` | awk 'sub(/inet /,""){print $1}')
292+
prop_nfshost_ip=${prop_use_ip:-"$(ifconfig -m `route get $prop_machine_ip | awk '{if ($1 ~ /interface:/){print $2}}'` | awk 'sub(/inet /,""){print $1}')"}
283293
if [ "" = "${prop_nfshost_ip}" ]; then
284294
echoError "Could not find the xhyve net IP!"; exit 1
285295
fi
@@ -289,8 +299,8 @@ lookupMandatoryProperties ()
289299

290300
if [ "$prop_machine_driver" = "parallels" ]; then
291301
prop_network_id="Shared"
292-
prop_nfshost_ip=$(prlsrvctl net info \
293-
"${prop_network_id}" | grep 'IPv4 address' | sed 's/.*: //')
302+
prop_nfshost_ip=${prop_use_ip:-"$(prlsrvctl net info \
303+
${prop_network_id} | grep 'IPv4 address' | sed 's/.*: //')"}
294304

295305
if [ "" = "${prop_nfshost_ip}" ]; then
296306
echoError "Could not find the parallels net IP!"; exit 1
@@ -300,6 +310,17 @@ lookupMandatoryProperties ()
300310
return
301311
fi
302312

313+
if [ "$prop_machine_driver" = "vmwarevsphere" ]; then
314+
prop_nfshost_ip=${prop_use_ip:-}
315+
316+
if [ "" = "${prop_nfshost_ip}" ]; then
317+
echoError "Need to explictly set ip to use with -p|--ip!"; exit 1
318+
fi
319+
320+
echoSuccess "OK"
321+
return
322+
fi
323+
303324
if [ "$prop_machine_driver" != "virtualbox" ]; then
304325
echoError "Unsupported docker-machine driver: $prop_machine_driver"; exit 1
305326
fi

0 commit comments

Comments
 (0)