machine icon indicating copy to clipboard operation
machine copied to clipboard

Stuck waiting for VM to start and Bad port '0' on virtualbox driver on mac

Open mattreyuk opened this issue 11 years ago • 23 comments

creating a virtualbox machine with docker-machine create --driver virtualbox devVM leads to output:

INFO[0000] Creating SSH key...
INFO[0001] Creating VirtualBox VM...
INFO[0010] Starting VirtualBox VM...
INFO[0011] Waiting for VM to start...

it then hangs. Looking at the virtualBox manager it shows the machine running. If i try and run other commands in another window (eg docker-machine ls ) I get the following:

Bad port '0' ERRO[0000] error getting URL for host devVM: exit status 255 NAME ACTIVE DRIVER STATE URL SWARM devVM virtualbox Running

mattreyuk avatar Mar 26 '15 02:03 mattreyuk

Hey thanks for reporting! We currently have a PR (https://github.com/docker/machine/pull/828) for this issue. It is in our allocation for a high port for virtualbox. You can usually fix the issue by removing the machine and re-creating.

ehazlett avatar Mar 26 '15 02:03 ehazlett

This should be fixed by #828 cc @ehazlett to close

nathanleclaire avatar Apr 01 '15 23:04 nathanleclaire

@mattreyuk please re-open if you experience again. thanks for reporting!

ehazlett avatar Apr 02 '15 13:04 ehazlett

I tried with a build from master [be9113a] that should have this fix in and I still have the same issue. I also tried upgrading my virtual box to 4.3.26 (prior was running 4.3.20) no dice.

mattreyuk avatar Apr 02 '15 22:04 mattreyuk

@mattreyuk Any chance you ran the command with -D mode and could paste the create output?

nathanleclaire avatar Apr 02 '15 23:04 nathanleclaire

Also, what's your base OS and is there any VPN or firewall at play?

nathanleclaire avatar Apr 02 '15 23:04 nathanleclaire

I'm away from my computer for a few days but I'll try that and report back.

mattreyuk avatar Apr 03 '15 02:04 mattreyuk

I'm using Arch Linux as a base OS, no VPN, no firewall, same problem with 2.0_rc3

# docker-machine create --driver virtualbox host1
INFO[0000] Creating SSH key...                          
INFO[0000] Creating VirtualBox VM...                    
INFO[0008] Starting VirtualBox VM...                    
INFO[0008] Waiting for VM to start...

and in another terminal:

# docker-machine -v
docker-machine version 0.2.0 (48bea37)
# docker-machine ls
Bad port '0'
ERRO[0000] error getting URL for host host1: exit status 255 
NAME    ACTIVE   DRIVER       STATE     URL   SWARM
host1            virtualbox   Running         
# vboxmanage list runningvms
"host1" {8b1efcb5-161c-49b0-a188-7134ccc40661}

nodefourtytwo avatar Apr 05 '15 12:04 nodefourtytwo

@nodefourtytwo thanks for reporting. can you report what you network scheme is? i.e. local IP and vbox host-only address space as well?

ehazlett avatar Apr 06 '15 20:04 ehazlett

Not sure that's what you're asking for but here it is: local IP is on 192.168.1.0/24 vbox IP is on 192.168.99.0/24

nodefourtytwo avatar Apr 06 '15 20:04 nodefourtytwo

@nathanleclaire I'm running OSX 10.9.5, no firewall, no VPN. I created a gist of the -D output at https://gist.github.com/mattreyuk/1ee391e845c1e21ad401 If I stop and restart the VM in the virtual box manager, it looks like it was created ok

mattreyuk avatar Apr 06 '15 22:04 mattreyuk

I'm still having issues with this as well, I've tried the following version:

docker-machine_darwin-amd64 version 0.2.0 (e4c2173)

Sometimes it managed to start a machine up, so it seems like it improved since version 0.1.0, but still hangs most of the times.

I'm running OSX 10.9.5 as well, with no particular network configuration.

bfil avatar Apr 15 '15 22:04 bfil

Thanks for the report @bfil . If you could paste some output of failed docker-machine -D create -d virtualbox foo type commands it would be very helpful! (note the -D - it's for debug output)

nathanleclaire avatar Apr 15 '15 22:04 nathanleclaire

No problem, here it is: https://gist.github.com/bfil/76498a4b019d1183487d

Just to confirm: it did work on my first attempt to generate this log, then the second time just got stuck at "Waiting for VM to start... ".

bfil avatar Apr 15 '15 22:04 bfil

This looks like perhaps another network related issue. We are seeing more of these.

@bfil could you paste the output of VBoxManager list hostonlyifs

ehazlett avatar Apr 16 '15 13:04 ehazlett

Having this same issue with the 0.2.0 prerelease...here's my output:

➜  ~  VBoxManage list hostonlyifs
Name:            vboxnet0
GUID:            786f6276-656e-4074-8000-0a0027000000
DHCP:            Disabled
IPAddress:       192.168.99.1
NetworkMask:     255.255.255.0
IPV6Address:
IPV6NetworkMaskPrefixLength: 0
HardwareAddress: 0a:00:27:00:00:00
MediumType:      Ethernet
Status:          Up
VBoxNetworkName: HostInterfaceNetworking-vboxnet0

Hope this helps

ruprict avatar Apr 16 '15 13:04 ruprict

@ehazlett here it is:

Name:            vboxnet0
GUID:            786f6276-656e-4074-8000-0a0027000000
DHCP:            Disabled
IPAddress:       192.168.59.3
NetworkMask:     255.255.255.0
IPV6Address:     
IPV6NetworkMaskPrefixLength: 0
HardwareAddress: 0a:00:27:00:00:00
MediumType:      Ethernet
Status:          Up
VBoxNetworkName: HostInterfaceNetworking-vboxnet0

Name:            vboxnet1
GUID:            786f6276-656e-4174-8000-0a0027000001
DHCP:            Disabled
IPAddress:       192.168.99.1
NetworkMask:     255.255.255.0
IPV6Address:     
IPV6NetworkMaskPrefixLength: 0
HardwareAddress: 0a:00:27:00:00:01
MediumType:      Ethernet
Status:          Up
VBoxNetworkName: HostInterfaceNetworking-vboxnet1

Name:            vboxnet2
GUID:            786f6276-656e-4274-8000-0a0027000002
DHCP:            Disabled
IPAddress:       192.168.33.1
NetworkMask:     255.255.255.0
IPV6Address:     
IPV6NetworkMaskPrefixLength: 0
HardwareAddress: 0a:00:27:00:00:02
MediumType:      Ethernet
Status:          Down
VBoxNetworkName: HostInterfaceNetworking-vboxnet2

Name:            vboxnet3
GUID:            786f6276-656e-4374-8000-0a0027000003
DHCP:            Disabled
IPAddress:       192.168.27.1
NetworkMask:     255.255.255.0
IPV6Address:     
IPV6NetworkMaskPrefixLength: 0
HardwareAddress: 0a:00:27:00:00:03
MediumType:      Ethernet
Status:          Down
VBoxNetworkName: HostInterfaceNetworking-vboxnet3

Name:            vboxnet4
GUID:            786f6276-656e-4474-8000-0a0027000004
DHCP:            Disabled
IPAddress:       10.0.0.1
NetworkMask:     255.255.255.0
IPV6Address:     
IPV6NetworkMaskPrefixLength: 0
HardwareAddress: 0a:00:27:00:00:04
MediumType:      Ethernet
Status:          Down
VBoxNetworkName: HostInterfaceNetworking-vboxnet4

Name:            vboxnet5
GUID:            786f6276-656e-4574-8000-0a0027000005
DHCP:            Disabled
IPAddress:       172.17.8.1
NetworkMask:     255.255.255.0
IPV6Address:     
IPV6NetworkMaskPrefixLength: 0
HardwareAddress: 0a:00:27:00:00:05
MediumType:      Ethernet
Status:          Down
VBoxNetworkName: HostInterfaceNetworking-vboxnet5

bfil avatar Apr 16 '15 14:04 bfil

To fix this, I removed the virtual network adapters created previously by chef and vagrant. It then worked.

pixeldrew avatar May 05 '15 20:05 pixeldrew

EDIT: I'm actually affected by #479

currently having a similar issue, mine starts OK but it seems docker-machine is not able to SSH into the machine.

full log: https://gist.github.com/kalbasit/03bf8464a6163d485a6f

I tried multiple times, I tried removing Vbox's adapter and no luck.

STDERR:
using 192.168.99.1 for dhcp address
executing: /usr/local/bin/VBoxManage list hostonlyifs
STDOUT: Name:            vboxnet0
GUID:            786f6276-656e-4074-8000-0a0027000000
DHCP:            Disabled
IPAddress:       192.168.99.1
NetworkMask:     255.255.255.0
IPV6Address:
IPV6NetworkMaskPrefixLength: 0
HardwareAddress: 0a:00:27:00:00:00
MediumType:      Ethernet
Status:          Up
VBoxNetworkName: HostInterfaceNetworking-vboxnet0


STDERR:
executing: /usr/local/bin/VBoxManage modifyvm dev --nic2 hostonly --nictype2 82540EM --hostonlyadapter2 vboxnet0 --cableconnected2 on
STDOUT:
STDERR:
executing: /usr/local/bin/VBoxManage modifyvm dev --natpf1 delete ssh
STDOUT:
STDERR: VBoxManage: error: Code NS_ERROR_INVALID_ARG (0x80070057) - Invalid argument value (extended info not available)
VBoxManage: error: Context: "RemoveRedirect(Bstr(ValueUnion.psz).raw())" at line 1717 of file VBoxManageModifyVM.cpp

executing: /usr/local/bin/VBoxManage modifyvm dev --natpf1 ssh,tcp,127.0.0.1,55896,,22
STDOUT:
STDERR:
executing: /usr/local/bin/VBoxManage startvm dev --type headless
STDOUT: Waiting for VM "dev" to power on...
VM "dev" has been successfully started.

STDERR:
Starting VM...
Getting to WaitForSSH function...
Testing TCP connection to: localhost:55896
Using SSH client type: external
About to run SSH command:
exit 0
&{/usr/bin/ssh [/usr/bin/ssh -o PasswordAuthentication=no -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=quiet -o ConnectionAttempts=3 -o ConnectTimeout=10 -i /Users/kalbasit/.docker/machine/machines/dev/id_rsa -p 55896 docker@localhost exit 0] []  <nil> <nil> <nil> [] <nil> <nil> <nil> <nil> false [] [] [] [] <nil>}

SSH cmd err, output: exit status 255:
Error getting ssh command 'exit 0' : exit status 255
Getting to WaitForSSH function...
Testing TCP connection to: localhost:55896
Using SSH client type: external
About to run SSH command:
exit 0
&{/usr/bin/ssh [/usr/bin/ssh -o PasswordAuthentication=no -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=quiet -o ConnectionAttempts=3 -o ConnectTimeout=10 -i /Users/kalbasit/.docker/machine/machines/dev/id_rsa -p 55896 docker@localhost exit 0] []  <nil> <nil> <nil> [] <nil> <nil> <nil> <nil> false [] [] [] [] <nil>}
SSH cmd err, output: exit status 255:
Error getting ssh command 'exit 0' : exit status 255
Getting to WaitForSSH function...
Testing TCP connection to: localhost:55896
Using SSH client type: external
About to run SSH command:
exit 0
&{/usr/bin/ssh [/usr/bin/ssh -o PasswordAuthentication=no -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=quiet -o ConnectionAttempts=3 -o ConnectTimeout=10 -i /Users/kalbasit/.docker/machine/machines/dev/id_rsa -p 55896 docker@localhost exit 0] []  <nil> <nil> <nil> [] <nil> <nil> <nil> <nil> false [] [] [] [] <nil>}

kalbasit avatar Jun 24 '15 19:06 kalbasit

I was getting this behavior as well. After reading through a bunch of issue comments, and trying a bunch of the suggestions, it turns out that modifying the stock ssh config was the fix. Props to @ctrlrsf for figuring it out, and validating it on his machine, too.

I'm running:

❯ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.10.4
BuildVersion:   14E46

The stock Yosemite ssh config looks like:

# Stop timing out connections
TCPKeepAlive no
ServerAliveInterval 60
ServerAliveCountMax 20

# SSH Connection pooling for faster additional connections to a machine
ControlMaster auto
ControlPath /tmp/ssh_mux_%h_%p_%r

# This makes subsequent connections go faster
ControlPersist 2h

# Make it so ssh-ing from one server to another passes keys around automagically
Host *
ForwardAgent yes

# Get rid of SSH connection delays
GSSAPIAuthentication no

I commented out all the config vars that match Control*, ran docker-machine rm dev, and then running docker-machine create dev --driver virtualbox finally succeeded.

Here's the new ssh config for reference:

# Stop timing out connections
TCPKeepAlive no
ServerAliveInterval 60
ServerAliveCountMax 20

# SSH Connection pooling for faster additional connections to a machine
#ControlMaster auto
#ControlPath /tmp/ssh_mux_%h_%p_%r

# This makes subsequent connections go faster
#ControlPersist 2h

# Make it so ssh-ing from one server to another passes keys around automagically
Host *
ForwardAgent yes

# Get rid of SSH connection delays
GSSAPIAuthentication no

diff

douglasjarquin avatar Jul 06 '15 19:07 douglasjarquin