Open letsgolesco opened 9 years ago
+1
+1
Docker tell me to regenerate certs if the IP changes, i need to set a static IP to avoid this problem or there is another solution?
eval "$(docker-machine env machine-1)"
Error running connection boilerplate: Error checking and/or regenerating the certs: There was an error validating certificates for host "192.168.99.101:2376": x509: certificate is valid for 192.168.99.108, not 192.168.99.101
You can attempt to regenerate them using 'docker-machine regenerate-certs name'.
Be advised that this will trigger a Docker daemon restart which will stop running containers.
+1 any ETA on this feature ?
A workaround for some use-cases could be to create machines like so:
192.168.98.100
docker-machine create -d virtualbox --virtualbox-hostonly-cidr "192.168.98.1/24" m98
192.168.97.100
docker-machine create -d virtualbox --virtualbox-hostonly-cidr "192.168.97.1/24" m97
192.168.96.100
docker-machine create -d virtualbox --virtualbox-hostonly-cidr "192.168.96.1/24" m96
If there's no other machine with the same cidr
, the machine should always get the .100
IP upon start.
@schmunk42 very good work around :+1:
My virtualbox has dhcp range 192.168.99.100 - 255 and I want to set an IP before 100.
I've found a simple trick to set a static IP: after create a machine i run this command and restart the machine:
echo "ifconfig eth1 192.168.99.50 netmask 255.255.255.0 broadcast 192.168.99.255 up" | docker-machine ssh prova-discovery sudo tee /var/lib/boot2docker/bootsync.sh > /dev/null
This command create a file bootsync.sh that is searched by boot2docker startup scripts and executed.
Now during machine boot the command is executed and set static IP.
docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM
test-1 - virtualbox Running tcp://192.168.99.50:2376 test-1 (master)
That's a good trick also @micheletedeschi :+1:
I like the way @micheletedeschi fixed this. Seems like an easy and standard way that doesn't involve modifications of docker-machine. Maybe this should be documented somewhere?
+1 I am working with 3 VM and i always have problems to connect via ssh and configuring my utils, hosts file etc.
+1
:+1:
+1
+1
+1
+1
+1 I'm trying to automate machine creation and can't expect to have permissions to add entries to /etc/hosts
over and over. Having a stable ip would mean only having to set this up once.
I ended up setting up a script that pre fills dnsmasq on the host using docker-machine ip
On 19 Dec 2015, at 12:18 PM, Pedro Cattori notifications@github.com wrote:
+1
— Reply to this email directly or view it on GitHub.
A very useful feature :+1:
Loving @micheletedeschi 's fix, though I wound up putting the IP on a virtual interface (replace eth1
with eth1:1
in the above command) since the eth1 interface is running DHCP and will eventually revert to the DHCP assigned IP address.
Not sure how long the dhcp lease refresh time is (ran for a day with the initial fix before I suddenly got the "you need to regenerate TLS certs" error and realized what was going on). Will report back if putting the IP on a virtual interface doesn't stick
@drags I've updated the commands with:
echo "kill `more /var/run/udhcpc.eth1.pid`\nifconfig eth1 192.168.99.50 netmask 255.255.255.0 broadcast 192.168.99.255 up" | docker-machine ssh prova-discovery sudo tee /var/lib/boot2docker/bootsync.sh > /dev/null
then run command (only the first time)
docker-machine regenerate-certs prova-discovery
now the IP will not be changed by the DHCP
:+1:
+1
:+1:
+1
+1
+1
Has anyone had luck scripting @micheletedeschi 's workaround? I want a single command everyone on the team can run to launch the dev vm. I tried the following:
docker-machine create -d virtualbox dev
echo "ifconfig eth1 192.168.99.50 netmask 255.255.255.0 broadcast 192.168.99.255 up" | docker-machine ssh dev sudo tee /var/lib/boot2docker/bootsync.sh > /dev/null
sleep 30
docker-machine restart dev
sleep 30
docker-machine regenerate-certs -f dev
When I run the commands manually it works. In the script, I had to put in the sleep 30 or the restart command would just hang. Now the script finishes successfully but after it runs the vm is still running with the old IP.
You could use vagrant to launch the docker machine and then use a plugin like vagrant-hostmanager. But of course then you've got other problems to deal with if you want it to be a single command to launch the VM cross-platform.
There's just no Perfect Solution at the present time (afaict).
Yeah, I think I'll stick with Vagrant for now.
I'm building a Vagrant box image with docker running with DOCKER_OPTS="-H 0.0.0.0:2375"
. Then I can create a vagrant vm with a private network hard-coded IP and use that IP to set DOCKER_HOST and /etc/hosts, which I think will be a pretty ideal setup.
+1,especially working with machine driver vmwarevsphere
+1
+1
+1
+1, just being able to set a machine's IP address. Currently the CLI only supports getting it. Using AWS Elastic IP's would require this. Otherwise the machine's config.json has to be manually updated.
~/.docker/machine/machines/my-machine-with-aws-elastic-ip/config.json
@dcosson w.r.t scripting.
I just start the docker-machine then run the following 2 commands (one to kill the dhcp client, two to set a static ip). I chose not to run 'docker restart' to trigger bootsync.sh. Perhaps that startup script doens't work? It's also possible the dhcp client was messing you up and resetting the eth1 IP on you.
echo "kill `more /var/run/udhcpc.eth1.pid`\nifconfig eth1 192.168.1.11 netmask 255.255.255.0 broadcast 192.168.99.255 up" | docker-machine ssh <machine-name> sudo tee /var/lib/boot2docker/bootsync.sh > /dev/null
docker-machine ssh <machine-name> "sudo ifconfig eth1 192.168.1.11 netmask 255.255.255.0 broadcast 192.168.1.255 up"
+1
+1
I had to slightly modify @roocell's snippet to kill the dhcp server immediately because I didn't want to reboot. Otherwise it would revert after a few minutes.
echo "kill `more /var/run/udhcpc.eth1.pid`\nifconfig eth1 192.168.1.11 netmask 255.255.255.0 broadcast 192.168.99.255 up" | docker-machine ssh <machine-name> sudo tee /var/lib/boot2docker/bootsync.sh > /dev/null
docker-machine ssh <machine-name> "sudo cat /var/run/udhcpc.eth1.pid | xargs sudo kill"
docker-machine ssh <machine-name> "sudo ifconfig eth1 192.168.1.11 netmask 255.255.255.0 broadcast 192.168.1.255 up"
I have a feeling that not setting a static ip on my machine running consul is what is giving me issues with respect to my swarm cluster. +1 for this
+1
+1
+1
+1
+1
+1_000000 :)
+1
Based on @micheletedeschi's comment, here is my script to set a fixed IP to a docker-machine VM:
http://stackoverflow.com/a/35367277/6309
+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!