Open letsgolesco opened 9 years ago
+1, need this feature
+1
+1
+1
Here's a good workaround. Add the following to your ~/.bash_profile
:
eval `docker-machine env <docker-machine name>`
export <some variable>=$(docker-machine ip <docker-machine name>)
@letsgolesco you can use --virtualbox-hostonly-cidr
option for that, which will select the proper vboxnetX
host-only adapter.
By default, seems docker-machine picks one randomly, so forced to use the one for vboxnet0
(192.168.59.3/24
, the one used by boot2docker) seems to solve the issue:
$ docker-machine create --driver virtualbox --virtualbox-hostonly-cidr "192.168.59.3/24" dev
Creating VirtualBox VM...
Creating SSH key...
Starting VirtualBox VM...
Starting VM...
To see how to connect Docker to this machine, run: docker-machine env dev
$ docker-machine ip dev
192.168.59.103
Cheers.
@luislavena - Unfortunately that did not work.
+1
Def need this feature though!
@krinkere not sure your env, but this worked for my OSX installation by doing that, but failed when using machine on Linux, which required tweaks to dhcpserver configuration of vboxnet0
:
$ VBoxManage dhcpserver modify --ifname vboxnet0 --disable
$ VBoxManage dhcpserver modify --ifname vboxnet0 --ip 192.168.59.3 --netmask 255.255.255.0 --lowerip 192.168.59.103 --upperip 192.168.59.203
$ VBoxManage dhcpserver modify --ifname vboxnet0 --enable
$ docker-machine create --driver "virtualbox" --virtualbox-cpu-count "-1" --virtualbox-disk-size "30000" --virtualbox-memory "2560" --virtualbox-hostonly-cidr "192.168.59.3/24" dev
This is, as you can see, a huge hack :smile_cat:, but works for now :smile:
Would love to see this feature!!
@luislavena - Thanks for your response
Here is what I get on my Mac.
$ docker-machine create --driver virtualbox --virtualbox-hostonly-cidr "192.168.99.3/24" dev Creating VirtualBox VM... Creating SSH key... Starting VirtualBox VM... Starting VM... To see how to connect Docker to this machine, run: docker-machine env dev
$ docker-machine ip dev 192.168.99.100
While I do have ip in the right subnet, it is not the IP that I would want to use... Def would love to see this feature
+1 usefull feature
+1 This feature would really help us out!
We use docker-machine to run a local Elasticsearch cluster and we have /etc/hosts
entry for 192.168.59.103
which maps to elastic-local.mycompany.com
. Since we have moved over to docker-machine from boot2docker, we have had to continuously manually update this hosts file entry to whatever is the new IP assigned to our docker VM. We could write some automation which would update this hosts file entry for us but it would be much simpler if docker-machine just let us use a configurable IP address for new machines.
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1 (y)
+1
+1
+1
Temporarily I am using some bash scripts to update the hosts files but is kludgy since you have to update /etc/hosts via sudo'd script but since you can get ip from docker-machine it works. I may share a gist.
ianlintner-wf, do share the script please. I'm about to write one exactly like that myself, but if I can not reinvent the wheel that'd be great.. yeah..
Here is the primary script I am using. I cleaned it up a little, but it lacks more formal default params and other stuff.
+1 please!
thanks for the script @ianlintner-wf. I have written one that dynamically adds the host/ip of any running docker machines. Have tested on OS X El Capitan.
The IP increment is cached by VirtualBox DHCP server. Stop and restart VirtualBox will reset the IP increment.
+1, our OSX devs are still using boot2docker because our env relies on static /etc/hosts entries. (btw thanks for the script @ianlintner-wf )
+1
+1
+1
+1
+2
My hacky-hack solution, which is definitely not for everyone: I'm running Cassandra in a docker machine, and I want to be able to get to it from the node.js app I'm developing. Rather than use a fixed IP for the docker machine, I do:
docker-machine stop dockervm
VBoxManage modifyvm "dockervm" --natpf1 "tcp-port9160,tcp,,9160,,9160"
VBoxManage modifyvm "dockervm" --natpf1 "tcp-port9042,tcp,,9042,,9042"
docker-machine start dockervm
eval "$(docker-machine env dockervm)"
which enables port forwarding for port tunnelling from localhost to the docker VM. Now I can just connect to localhost:9042. (This would be much easier if someone were to fix https://github.com/docker/machine/issues/41. :D)
@luislavena thank you, just recreated default machine with these options and everything works fine now
+1
+1, I will try the script with the automatic update of hosts file, but definitely I want this feature!
Based on @cookandy & @ianlintner-wf script, I've created mine.
You can configure it with a map between docker-machine-name and host name.
It will update your hosts by removing older docker machine ips and a new ones
+1
:+1:
+1
+1
:+1:
+1
Hi, I've been searching through the docs and issues to figure this out but can't find an answer.
Basically, I want to be able to specify the IP address of a VM (i.e. the value that's listed under "URL" in
docker-machine ls
) when I create it withdocker-machine create
.I want this because I've been relying on boot2docker's default address of 192.168.59.103, but now it varies from machine to machine.
Thanks!