virtualbox: intermittent machine create fails
~~If running --virtualbox-disk-size docker-machine create on OSX, no new docker machines can be generated anymore. To resolve, .docker needs to be deleted.~~
~~After deleting .docker, creating a machine works flawlessly again.~~
Please see my first comment for updated information
Behaviour
Most of the times, docker-machine ~~--virtualbox-disk-size~~ waits endlessly for VM to start, although it was started already (regarding to virtualbox).
Stopping the start process, docker ls shows the instance as running, without URL however:
dockermachine ls
NAME ACTIVE DRIVER STATE URL
mine virtualbox Running
dockermachine config mine
Bad port '0'
FATA[0000] Error getting machine url: exit status 255
thanks for reporting. I just confirmed this is working. Can you paste the exact create command you used?
@ramschmaerchen there was a bug with the way the cli args were processed. could you try this again from master and see if it still errors? thx
Ok, I tried to investigate this issue further.
First of all, master did not fix it.
Specs
- OSX 10.9.5
- docker-machine master branch (0.1.0, 2.4.2015)
- docker 1.4.1
- boot2docker not installed (well, uninstalled,...)
- VirtualBox 4.3.20 r96996
Investigation
- The behaviour is not reproducible, at least not yet
- Sometimes, machines are created successfully, sometimes they are not.
- Failure is not dependent on --virtual-disk-size ~~anymore (?) (master branch). I guess --virtual-disk-size could be misleading.~~
Step by step
docker-machine create -d virtualbox dev- Endlessly
Waiting for VM to start... docker-machine lsshows that the machine did start, but did not get a URI- Shutting dev down via VirtualBox
- Starting dev via VirtualBox
- The machine dev generates a new server certificate on docker init
- Shutting dev down via virtualbox
docker-machine start devWaiting for VM to start...endlessly- Virtualmachine shows that, again, this machine generated a new cert on start
Build TLS certs for...
Conclusion
The only thing I could see was, that non-working machines are generating a new certificate in the docker init process on every boot.
Side effects
Both, working and non-working machines, fail on ipv6
The IPv6 support in machine for virtual box doesn't exist, I'm not sure anyone has tried yet.
But we should look into why this is failing. I'd also like to see unified arguments for drivers. There's no reason drivers can't share flags. Things like disk size, ram and auth credentials could be reused.
+1 sthulb
@ramschmaerchen could you also run the command with debug (docker-machine -D create -d virtualbox ...). This will help us troubleshoot as well.
Sure. I censored keys and stuff but made sure the keys and names are the same (same name for same key)
Working machine
dockermachine -D create -d virtualbox dev
INFO[0001] Creating SSH key... DEBU[0001] executing: /usr/bin/ssh-keygen ssh-keygen -t rsa -N -f /Users/thisuser/.docker/machines/dev/id_rsa
Generating public/private rsa key pair. Your identification has been saved in /Users/thisuser/.docker/machines/dev/id_rsa. Your public key has been saved in /Users/thisuser/.docker/machines/dev/id_rsa.pub. The key fingerprint is: foobar thisuser@localhost The key's randomart image is: +--[ RSA 2048]----+ | foobar | +-----------------+ INFO[0001] Creating VirtualBox VM... DEBU[0001] Creating 20000 MB hard disk image... Converting from raw image file="stdin" to file="/Users/thisuser/.docker/machines/dev/disk.vmdk"... Creating dynamic image with size 20971520000 bytes (20000MB)... DEBU[0017] executing: VBoxManage createvm --basefolder /Users/thisuser/.docker/machines/dev --name dev --register Virtual machine 'dev' is created and registered. UUID: d6ec89a6-98d1-40b7-85c5-79d109230e9a Settings file: '/Users/thisuser/.docker/machines/dev/dev/dev.vbox' DEBU[0017] executing: VBoxManage modifyvm dev --firmware bios --bioslogofadein off --bioslogofadeout off --natdnshostresolver1 on --bioslogodisplaytime 0 --biosbootmenu disabled --ostype Linux26_64 --cpus 2 --memory 1024 --acpi on --ioapic on --rtcuseutc on --cpuhotplug off --pae on --synthcpu off --hpet on --hwvirtex on --nestedpaging on --largepages on --vtxvpid on --accelerate3d off --boot1 dvd DEBU[0018] executing: VBoxManage modifyvm dev --nic1 nat --nictype1 virtio --cableconnected1 on DEBU[0018] executing: VBoxManage modifyvm dev --natpf1 ssh,tcp,127.0.0.1,49178,,22 DEBU[0018] executing: VBoxManage list hostonlyifs DEBU[0018] executing: VBoxManage modifyvm dev --nic2 hostonly --nictype2 virtio --hostonlyadapter2 vboxnet2 --cableconnected2 on DEBU[0018] executing: VBoxManage storagectl dev --name SATA --add sata --hostiocache on DEBU[0018] executing: VBoxManage storageattach dev --storagectl SATA --port 0 --device 0 --type dvddrive --medium /Users/thisuser/.docker/machines/dev/boot2docker.iso DEBU[0018] executing: VBoxManage storageattach dev --storagectl SATA --port 1 --device 0 --type hdd --medium /Users/thisuser/.docker/machines/dev/disk.vmdk DEBU[0018] executing: VBoxManage guestproperty set dev /VirtualBox/GuestAdd/SharedFolders/MountPrefix / DEBU[0018] executing: VBoxManage guestproperty set dev /VirtualBox/GuestAdd/SharedFolders/MountDir / DEBU[0018] executing: VBoxManage sharedfolder add dev --name Users --hostpath /Users --automount DEBU[0018] executing: VBoxManage setextradata dev VBoxInternal2/SharedFoldersEnableSymlinksCreate/Users 1 INFO[0018] Starting VirtualBox VM... DEBU[0018] executing: VBoxManage startvm dev --type headless Waiting for VM "dev" to power on... VM "dev" has been successfully started. INFO[0019] Waiting for VM to start... DEBU[0062] executing: ssh -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=quiet -p 49178 -i /Users/thisuser/.docker/machines/dev/id_rsa docker@localhost sudo hostname dev && echo "dev" | sudo tee /var/lib/boot2docker/etc/hostname dev DEBU[0066] executing: VBoxManage showvminfo dev --machinereadable DEBU[0066] executing: ssh -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=quiet -p 49178 -i /Users/thisuser/.docker/machines/dev/id_rsa docker@localhost ip addr show dev eth1 DEBU[0066] SSH returned: 4: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 08:00:27:98:75:ca brd ff:ff:ff:ff:ff:ff inet 192.168.99.100/24 brd 192.168.99.255 scope global eth1 valid_lft forever preferred_lft forever inet6 fe80::a00:27ff:fe98:75ca/64 scope link valid_lft forever preferred_lft forever
END SSH
DEBU[0066] generating server cert: /Users/thisuser/.docker/machines/dev/server.pem DEBU[0067] Stopping Docker... DEBU[0067] executing: ssh -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=quiet -p 49178 -i /Users/thisuser/.docker/machines/dev/id_rsa docker@localhost if [ -e /var/run/docker.pid ]; then sudo /etc/init.d/docker stop ; fi DEBU[0068] executing: ssh -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=quiet -p 49178 -i /Users/thisuser/.docker/machines/dev/id_rsa docker@localhost sudo mkdir -p /var/lib/boot2docker DEBU[0068] executing: ssh -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=quiet -p 49178 -i /Users/thisuser/.docker/machines/dev/id_rsa docker@localhost echo "-----BEGIN CERTIFICATE----- Mycert -----END CERTIFICATE----- " | sudo tee -a /var/lib/boot2docker/ca.pem -----BEGIN CERTIFICATE----- Mycert -----END CERTIFICATE-----
DEBU[0068] executing: ssh -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=quiet -p 49178 -i /Users/thisuser/.docker/machines/dev/id_rsa docker@localhost echo "-----BEGIN RSA PRIVATE KEY----- superkey== -----END RSA PRIVATE KEY----- " | sudo tee -a /var/lib/boot2docker/server-key.pem -----BEGIN RSA PRIVATE KEY----- superkey== -----END RSA PRIVATE KEY-----
DEBU[0068] executing: ssh -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=quiet -p 49178 -i /Users/thisuser/.docker/machines/dev/id_rsa docker@localhost echo "-----BEGIN CERTIFICATE----- boringcert -----END CERTIFICATE----- " | sudo tee -a /var/lib/boot2docker/server.pem -----BEGIN CERTIFICATE----- boringcert -----END CERTIFICATE-----
DEBU[0068] executing: VBoxManage showvminfo dev --machinereadable DEBU[0068] executing: ssh -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=quiet -p 49178 -i /Users/thisuser/.docker/machines/dev/id_rsa docker@localhost ip addr show dev eth1 DEBU[0068] SSH returned: 4: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 08:00:27:98:75:ca brd ff:ff:ff:ff:ff:ff inet 192.168.99.100/24 brd 192.168.99.255 scope global eth1 valid_lft forever preferred_lft forever inet6 fe80::a00:27ff:fe98:75ca/64 scope link valid_lft forever preferred_lft forever
END SSH
DEBU[0068] executing: ssh -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=quiet -p 49178 -i /Users/thisuser/.docker/machines/dev/id_rsa docker@localhost echo "EXTRA_ARGS='--tlsverify
--tlscacert=/var/lib/boot2docker/ca.pem
--tlskey=/var/lib/boot2docker/server-key.pem
--tlscert=/var/lib/boot2docker/server.pem -H tcp://0.0.0.0:2376'
CACERT=/var/lib/boot2docker/ca.pem
SERVERCERT=/var/lib/boot2docker/server-key.pem
SERVERKEY=/var/lib/boot2docker/server.pem
DOCKER_TLS=no" | sudo tee -a /var/lib/boot2docker/profile
EXTRA_ARGS='--tlsverify --tlscacert=/var/lib/boot2docker/ca.pem --tlskey=/var/lib/boot2docker/server-key.pem --tlscert=/var/lib/boot2docker/server.pem -H tcp://0.0.0.0:2376'
CACERT=/var/lib/boot2docker/ca.pem
SERVERCERT=/var/lib/boot2docker/server-key.pem
SERVERKEY=/var/lib/boot2docker/server.pem
DOCKER_TLS=no
DEBU[0068] Starting Docker...
DEBU[0068] executing: ssh -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=quiet -p 49178 -i /Users/thisuser/.docker/machines/dev/id_rsa docker@localhost sudo /etc/init.d/docker start
INFO[0069] "dev" has been created and is now the active machine
INFO[0069] Configure docker client with: $(dockermachine env dev)
The non-working machine is not generating certs and keys upon creation.
Non-Working Machine
dockermachine -D create -d virtualbox dev2
INFO[0001] Creating SSH key... DEBU[0001] executing: /usr/bin/ssh-keygen ssh-keygen -t rsa -N -f /Users/thisuser/.docker/machines/dev2/id_rsa
Generating public/private rsa key pair. Your identification has been saved in /Users/thisuser/.docker/machines/dev2/id_rsa. Your public key has been saved in /Users/thisuser/.docker/machines/dev2/id_rsa.pub. The key fingerprint is: myfingerprint thisuser@localhost The key's randomart image is: +--[ RSA 2048]----+ | myfingerprint | +-----------------+ INFO[0001] Creating VirtualBox VM... DEBU[0001] Creating 20000 MB hard disk image... Converting from raw image file="stdin" to file="/Users/thisuser/.docker/machines/dev2/disk.vmdk"... Creating dynamic image with size 20971520000 bytes (20000MB)... DEBU[0020] executing: VBoxManage createvm --basefolder /Users/thisuser/.docker/machines/dev2 --name dev2 --register Virtual machine 'dev2' is created and registered. UUID: b743f20e-fcc9-4c26-8c63-fb5f4e8ef423 Settings file: '/Users/thisuser/.docker/machines/dev2/dev2/dev2.vbox' DEBU[0020] executing: VBoxManage modifyvm dev2 --firmware bios --bioslogofadein off --bioslogofadeout off --natdnshostresolver1 on --bioslogodisplaytime 0 --biosbootmenu disabled --ostype Linux26_64 --cpus 2 --memory 1024 --acpi on --ioapic on --rtcuseutc on --cpuhotplug off --pae on --synthcpu off --hpet on --hwvirtex on --nestedpaging on --largepages on --vtxvpid on --accelerate3d off --boot1 dvd DEBU[0020] executing: VBoxManage modifyvm dev2 --nic1 nat --nictype1 virtio --cableconnected1 on DEBU[0020] executing: VBoxManage modifyvm dev2 --natpf1 ssh,tcp,127.0.0.1,49175,,22 DEBU[0020] executing: VBoxManage list hostonlyifs DEBU[0020] executing: VBoxManage modifyvm dev2 --nic2 hostonly --nictype2 virtio --hostonlyadapter2 vboxnet2 --cableconnected2 on DEBU[0021] executing: VBoxManage storagectl dev2 --name SATA --add sata --hostiocache on DEBU[0021] executing: VBoxManage storageattach dev2 --storagectl SATA --port 0 --device 0 --type dvddrive --medium /Users/thisuser/.docker/machines/dev2/boot2docker.iso DEBU[0021] executing: VBoxManage storageattach dev2 --storagectl SATA --port 1 --device 0 --type hdd --medium /Users/thisuser/.docker/machines/dev2/disk.vmdk DEBU[0021] executing: VBoxManage guestproperty set dev2 /VirtualBox/GuestAdd/SharedFolders/MountPrefix / DEBU[0021] executing: VBoxManage guestproperty set dev2 /VirtualBox/GuestAdd/SharedFolders/MountDir / DEBU[0021] executing: VBoxManage sharedfolder add dev2 --name Users --hostpath /Users --automount DEBU[0021] executing: VBoxManage setextradata dev2 VBoxInternal2/SharedFoldersEnableSymlinksCreate/Users 1 INFO[0021] Starting VirtualBox VM... DEBU[0021] executing: VBoxManage startvm dev2 --type headless Waiting for VM "dev2" to power on... VM "dev2" has been successfully started.
Thanks. Could you also post the actual machine command line you are running?
Sure, nothing fancy:
dockermachine -D create -d virtualbox dev
Edited the comments above.
Ok. Is this from the RC2 or master? Also, can you try to remove (or backup) the existing ~/.docker/machines directory and try creation again?
I guess the obvious question is what is the difference between machines? OS version, arch, VirtualBox version, etc?
Besides of the original entry, I always used master branch 4th Feb 2015.
Sorry for not mentioning: Removing .docker does not fix anything. I did not edit the original message as I was trying with RC2 then. ~~With RC2, removing .docker worked.~~ With master, everything is happening by chance. Sometimes it works, sometimes not. There is no way I am able to tell why it works.
Here is what I tried between creation of new machines:
- Restarting the Computer
- Starting / Stopping with dockermachine
- Starting / Stopping with virtualbox
- Removing .docker
I created 100 machines the last two days and was not able to figure out any pattern.
Ok so just to confirm, it is working some times? If that's the case, what is your Host OS (version) and VirtualBox version of the machine that isn't working?
Yes, sometimes it is working, sometimes it is not, as mentioned in the comments. Specs are in the third comment. I added VirtualBox information. Quick access: VirtualBox 4.3.20 r96996
After several tests I can confirm that RC2 is NOT working any better if .docker has been deleted before creating new machines.
I have, with a decent enough level of frequency to be considered worrisome, gotten that "Bad port '0'" error from VBox machines as well.
Same here, sometimes it works, most of the time not.
DEBU[0025] STDOUT: Waiting for VM "node1" to power on...
VM "node1" has been successfully started.
DEBU[0025] STDERR:
INFO[0025] Waiting for VM to start...
For example, I made a script that create 5 docker-machine with the driver virtualbox (one is going to be a swarm-master, the other agents) for a demo. The creation of the first machine is ok, then it fails most of the time on the second one (hanging on Waiting for VM to start...).
Cleaning $HOME/.docker, $HOME/.config/VirtualBox, remove dhcpservers (VBoxManage dhcpserver remove --netname HostInterfaceNetworking-vboxnetX) and hostonly interfaces (vboxmanage hostonlyif remove vboxnet0) doesn't make it work better. No real idea why it's hanging though..
@vdemeester are you adding delays in the script? with VirtualBox, if you create the VMs too quickly, virtualbox will do that exact error. For example, in @nathanleclaire multiple instance PR, he doesn't launch them concurrently but rather queues them because of this behavior.
@ehazlett Yes I added a delay 5 to 10s and it's working a little better, few of nodes have created but in the end I got same error for one node.
What's strange is that docker-machine is waiting for the VM to start, but if I look at the VirtualBox machine (using the UI), I see that boot2docker is started.. It seems that for a reason I don't know, docker-machine do not detect that it's started in some cases. I'll try to take a look at the driver code (my golang knowledge is kinda small but :P), on how it's checking the availability of the VM.
@vdemeester Sorry to hear about the trouble. Could you please post the following information when you get a chance (it will help greatly in debugging):
- Host OS and OS version
- Virtualbox Version
- Full debug output from a failed command
Thanks!
@vdemeester that's the same behavior I've seen too. You can see the thumbnail of it running but never gets an IP. I think it would be beneficial to add a flag to not make the VM headless -- then we could at least login via the console to debug.