Open letsgolesco opened 9 years ago
+1
I have a case where I use dnsmaq for DHCP and DNS, based on the comments above I tried disabling the DHCP server of the virtual box interface in my case its vboxnet4
like VBoxManage dhcpserver remove --netname HostInterfaceNetworking-vboxnet4
and need to reboot the machine to pick the DHCP range from dnsmasq
, the issue am facing is that on every new machine creation the docker-machine is enabling dhcp sever on vboxnet4
and other servers using dnsmasq are not able to look up the docker-machine(s), i have to repeat the removal of vnet and then reboot docker-machines. it will be great if we can add a flag to docker-machine-create to help no enable dhcp kind of thing.
+1
+1
+1
+1
Here's a command that encapsulates @micheletedeschi's work and provides some convenience for switching between DHCP and static configurations. It also updates your /etc/hosts
file if requested.
https://github.com/fivestars/docker-machine-ipconfig
We've been using it for the last few weeks with great success. Just run it right after creating your docker machine.
Usage: docker-machine-ipconfig <command> args...
Commands:
ls List running docker-machines' ip addresses
static <machine> [ip-address] Configure <machine> to use a static IP address
(default is current address)
dhcp <machine> Configure <machine> to use DHCP client to gather IP address
hosts Update /etc/hosts file
Everyone was thinking on a more "generic" solution (docker-machine native feature) as this option is interesting also on Vsphere, Azure and other deploy environments. But it's truly welcome.
+1
+1
+1
+1
+1
+1
@micheletedeschi's workaround more or less works for me, but it appears that the ip occasionally reverts from the one I set it to with his script (192.168.99.100:2376) to the one that was auto generated when I created my machine (192.168.99.104:2376). Fairly new to docker, anyone have any insight?
+1, ran into same issue today using ZooKeeper and VirtualBox
@micheletedeschi's workaround more or less works for me, but it appears that the ip occasionally reverts from the one I set it to with his script (192.168.99.100:2376) to the one that was auto generated when I created my machine (192.168.99.104:2376). Fairly new to docker, anyone have any insight?
Are you killing the DHCP client? After it reverts, can you confirm the DHCP client is still not running?
I found another workaround that finally works for me: I simply start the swarm agent on each machine using advertise=$(ifconfig eth1 | grep -Eo "192.168.99.1[0-9]{2}"):2376 and publish the current IP to ZooKeeper (or any other discovery service). This is ok in my case since I can rely on each machine getting assigned a 192.168.99.1\ address (it's just an experimental setup). think there're more advanced regex expressions that can be applied to arbitrary IP ranges. This is not nice and might be kinda hacky, but it does the job.
+1
+1
Arbitrarily-changing VM IPs and TLS certs that suddenly become invalid upon reboot has caused lots of gotcha moments and wasted man-hours
Is this even prioritised? A whole 13 months this case has been open. +10000
My guess is that there is a philosophical disagreement between some people on the docker machine team and the rest of the world on this issue. Using DHCP and having a non deterministic IP is pretty much worthless for all of my uses cases.
I have been using this workaround for the last year. It is adapted from some of the one-liner workarounds described above.
SSH onto the docker machine docker-machine ssh default
Add/edit the boot2docker startup script sudo vi /var/lib/boot2docker/bootsync.sh
#!/bin/sh
/etc/init.d/services/dhcp stop
ifconfig eth1 192.168.99.50 netmask 255.255.255.0 broadcast 192.168.99.255 up
sudo chmod 755 /var/lib/boot2docker/bootsync.sh exit
Restart machine and regenerate certs docker-machine restart default docker-machine regenerate-certs default
+1
+1
+1 (for docker-machine and jimmidyson/minishift)
+1
@eytanhanig Unfortunately your method did not work for me. I'm on OS X 10.11.6. The machines get the desired IPs but there is an error connecting to them. Docker suggests regenerating keys, but that did not fix the issue.
+1
+1
It's ridiculous how long people have been +1ing this.
+1
I love the have this feature, however, I didn't find any elegant approach to implement it.
The problem is caused by the DHCP in Virtualbox, if the system reboot, the DHCP server will lost all allocated IPs data, and try to reallocate the IP for those VM, which not likely to have the same IP for the last time.
I'm not sure it's right to let the Virtualbox to persistent the DHCP data. And Boot2docker will not persistent the IP allocated by DHCP, which is actually correct behavior.
IMHO, I don't think try to workaround the DHCP is the right way to do, I think adding the ability to specify a static IP to Boot2docker and docker-machine virtualbox driver should solve the problem.
It's maybe better to implement the static IP in https://github.com/boot2docker/boot2docker project first, such as, adding an ability to be specified a static IP, rather than using DHCP.
Here is the code to triggers DHCP call:
https://github.com/boot2docker/boot2docker/blob/master/rootfs/rootfs/bootscript.sh#L16
# Trigger the DHCP request sooner (the x64 bit userspace appears to be a second slower)
echo "$(date) dhcp -------------------------------"
/etc/rc.d/dhcp.sh
echo "$(date) dhcp -------------------------------"
We can make it conditional, by adding a set of IP configuration in /var/lib/boot2docker/profile
, and if a static IP has been configured, then use the static IP instead of request IP from DHCP.
Then, we can add one or more options for virtualbox
driver to specify the static IP configuration, such as --virtualbox-boot2docker-cidr
, --virtualbox-boot2docker-gateway
, --virtualbox-boot2docker-dns
...
+1
+1
+1
Guys, come on. Could we please stop +1 on an obviously long-running issue? There was a Like button implemented for that particular reason. No need to spam the subscribers.
No need to spam the subscribers.
You can unsubscribe.
I'm all for spamming the subscribers.
Some of those subscribers are part of the project team.
On 26 Jan 2017 14:20, "Sergey Nevmerzhitsky" notifications@github.com wrote:
No need to spam the subscribers.
You can unsubscribe. [image: 1] https://cloud.githubusercontent.com/assets/1006042/22332699/4cf1a8b4-e3e3-11e6-8bad-52406c3b8055.png
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/docker/machine/issues/1709#issuecomment-275386350, or mute the thread https://github.com/notifications/unsubscribe-auth/AG44NZ2KdnsH6JTU6iI_5Uieh9WZxWXBks5rWJ2RgaJpZM4FsQYg .
I'm all for spamming the subscribers. Some of those subscribers are part of the project team.
Maintainer checking in. Please do not do spam the issue with +1 comments. This is a well known issue and spamming the thread doesn't do any good. Indicate support through the "+1" emoji reactions if you'd like. As always, we're happy to evaluate pull requests or detailed proposals. Thanks all.
(As a side note, @twang2218 seems to have the right idea generally -- static IPs are trickier than they look to get right and hit the use cases subscribers to this thread might have in mind -- perhaps an issue could be started in the boot2docker repo to discuss.)
I do not really want a static ip. But once the ip address is picked during creation, it should keep it on subsequent restarts. Is this already available?
I had a docker with VPN and the standard 192.168.99.100 wasn't loading. I figured this was because of the VPN connection, so I setup a bridge network inside Virtualbox to access the docker via 192.168.1.159. I would like this to show up on Kitematic's published IP address. Is there any way to do so?
For those who can not wait this feature to be implemented, assigning custom ip, plus custom cpu/memory is possible by using Vagrant VirtualBox provider and docker-machine generic driver.
For example in windows, place this Vagrantfile:
Vagrant.configure("2") do |config|
config.vm.box = "AlbanMontaigu/boot2docker"
config.vm.provider "virtualbox" do |v|
v.memory = 8192
v.cpus = 8
end
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.synced_folder "C:/Users", "/c/Users"
config.vm.network "private_network", ip: "192.168.99.103"
end
and place vagrant default ssh private key with name vagrant.pem
and run
vagrant up
docker-machine create --driver generic --generic-ip-address=192.168.99.103 --generic-ssh-user=docker --generic-ssh-key=vagrant.pem default
docker-machine ls
and you'll get docker host with custom ip, cpu, memory etc configured via vagrant at the same time accessible via docker-machine.
You can find working file set for Windows in https://github.com/joelhandwell/dockerhost
@jcwilson Hi Josh et al, thanks a lot.. I forked your script in order to fix the same issue (see https://github.com/minishift/minishift/issues/343 , https://github.com/minishift/minishift/issues/598) in combination with minishift:
Any news?
Currently, I am experimenting with this for Minishift: https://github.com/minishift/minishift/issues/1293 Although, another approach would be to use something like cloud-init (which is maybe to heavy for this approach, or embed a DHCP server inside the Go-based binary and use this to force an allocated IP address)
+1. Currently having more than one machine is horrific pain. If you use additional certificates (for example, for custom docker repository) and change order of starting machines, you have to do:
Error checking TLS connection: Error checking and/or regenerating the certs: There was an error validating certificates for host "192.168.99.100:2376"
: x509: certificate is valid for 192.168.99.101, not 192.168.99.100
This forces you to regenerate certificates or disable all machines and restore order of executing (what sometimes can be painful, too).
Additionally, using Chef to configure Docker-based project would also be much better if you could assume created machine would have always the same IP (for example, adding it to hosts file and you could forget about IPs).
+1
+1
+1 thx jcwilson, the script docker-machine-ipconfig is very good! i needed to alter the eth1 to eth0 in the script, after this, the script working perfect for me. I'm use vmware vsphere.
bye.
+1
As part of minishift, we have implemented https://github.com/minishift/minishift/issues/1316 and this has been working well so far. We are now looking into alternatives to do the same for the other hypervisors over time, but first we will fix the address using https://github.com/minishift/minishift/issues/1457 (to prevent a new address from being assigned). We haven't been able to reserve time yet, we are going to land this in minikube too.
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!