Skip to content
This repository has been archived by the owner on Sep 26, 2021. It is now read-only.

How I can create a virtualbox machine offline? #539

Closed
rossbachp opened this issue Feb 14, 2015 · 32 comments · Fixed by #805 or #821
Closed

How I can create a virtualbox machine offline? #539

rossbachp opened this issue Feb 14, 2015 · 32 comments · Fixed by #805 or #821

Comments

@rossbachp
Copy link

I tested with absolute file and file:/// scheme, but with no success.

Many thanks
Peter

$ docker-machine create -d virtualbox tomcat-2 --virtualbox-boot2docker-url ///Users/xxx/.docker/machines/tomcat/boot2docker.iso 
ERRO[0000] Error creating machine: Get https://api.github.com/repos/boot2docker/boot2docker/releases: dial tcp: stat /etc/resolv.conf: no such file or directory 
WARN[0000] You will want to check the provider to make sure the machine and associated resources were properly removed. 
FATA[0000] Error creating machine                       
$ docker-machine rm tomcat-2
INFO[0000] machine does not exist, assuming it has been removed already 
$ docker-machine create -d virtualbox tomcat-2 --virtualbox-boot2docker-url /Users/xxx/.docker/machines/tomcat/boot2docker.iso 
ERRO[0000] Error creating machine: Get https://api.github.com/repos/boot2docker/boot2docker/releases: dial tcp: stat /etc/resolv.conf: no such file or directory 
WARN[0000] You will want to check the provider to make sure the machine and associated resources were properly removed. 
FATA[0000] Error creating machine                       
$ docker-machine rm tomcat-2
INFO[0000] machine does not exist, assuming it has been removed already 
$ docker-machine create -d virtualbox tomcat-2 --virtualbox-boot2docker-url file:///Users/xxx/.docker/machines/tomcat/boot2docker.iso 
ERRO[0000] Error creating machine: Get https://api.github.com/repos/boot2docker/boot2docker/releases: dial tcp: stat /etc/resolv.conf: no such file or directory 
WARN[0000] You will want to check the provider to make sure the machine and associated resources were properly removed. 
FATA[0000] Error creating machine                       
@ehazlett
Copy link
Contributor

We should skip the release check if a file is specified. Thanks for reporting.

@rossbachp
Copy link
Author

Great:) Many thanks!

@ehazlett ehazlett added this to the 0.2.0 milestone Feb 26, 2015
@ehazlett ehazlett modified the milestone: 0.2.0 Mar 17, 2015
@arun-gupta
Copy link

This is very relevant in a hackathon setup.

@hairyhenderson
Copy link
Contributor

Is this still an issue in HEAD? the code in virtualbox.go seems to imply that the release check only occurs if no b2d ISO URL was specified.

@hairyhenderson
Copy link
Contributor

Oh! This might just be a flag issue. I seem to recall running into this a while back.

Try putting a = between the flag and the argument:

$ docker-machine create -d virtualbox tomcat-2 --virtualbox-boot2docker-url=file:///Users/xxx/.docker/machines/tomcat/boot2docker.iso

@ehazlett
Copy link
Contributor

Hmm looks like a regression. I'm getting unsupported protocol scheme when trying to use the file. Checking.

@rossbachp
Copy link
Author

virtualbox driver use a http.client module. It doesn't support file scheme!

@md5
Copy link

md5 commented Mar 18, 2015

It doesn't out of the box, but it can: http://golang.org/pkg/net/http/#Transport.RegisterProtocol

@md5
Copy link

md5 commented Mar 18, 2015

This looks relevant too: https://golang.org/src/net/http/filetransport.go

@ehazlett
Copy link
Contributor

@hairyhenderson @arun-gupta #805 should fix this. Would you mind testing? Thanks!

@arun-gupta
Copy link

Sure, I can. Which repository should I checkout?

@ehazlett
Copy link
Contributor

@arun-gupta #805

@arun-gupta
Copy link

@ehazlett This is likely a git noob question :)

How do I clone that repo?

@ehazlett
Copy link
Contributor

@arun-gupta ah np :) i can give you a test build. What platform are you on (OS/arch)?

@arun-gupta
Copy link

@ehazlett OSX, thanks!

@ehazlett
Copy link
Contributor

@rossbachp
Copy link
Author

Hi Evan,

works

$ cp ~/.docker/images/boot2docker.iso .
$ chmod +x docker-machine_darwin-amd64 
$ ./docker-machine_darwin-amd64 create -d virtualbox tomcat-2 --virtualbox-boot2docker-url=file:///$(pwd)/boot2docker.iso
INFO[0001] Creating SSH key...                          
INFO[0001] Creating VirtualBox VM...                    
INFO[0009] Starting VirtualBox VM...                    
INFO[0010] Waiting for VM to start...                   
INFO[0044] "tomcat-2" has been created and is now the active machine. 
INFO[0044] To point your Docker client at it, run this in your shell: eval "$(docker-machine_darwin-amd64 env tomcat-2)" 

But I got a strange ls error with the binary with ls

$ ./docker-machine_darwin-amd64 ls
panic: runtime error: index out of range

goroutine 16 [running]:
runtime.panic(0x6538e0, 0xa5935c)
    /usr/src/go/src/pkg/runtime/panic.c:279 +0xf5
github.com/skarademir/naturalsort.NaturalSort.Less(0x208fbc380, 0x8, 0x8, 0x0, 0x6, 0x0)
    /go/src/github.com/docker/machine/Godeps/_workspace/src/github.com/skarademir/naturalsort/naturalsort.go:23 +0x4f8
github.com/skarademir/naturalsort.(*NaturalSort).Less(0x208f17660, 0x0, 0x6, 0x0)
    <autogenerated>:3 +0xa6
sort.doPivot(0x2208b60c08, 0x208f17660, 0x0, 0x8, 0x200000000, 0x39992)
    /usr/src/go/src/pkg/sort/sort.go:129 +0x4ac
sort.quickSort(0x2208b60c08, 0x208f17660, 0x0, 0x8, 0x7)
    /usr/src/go/src/pkg/sort/sort.go:173 +0xa8
sort.Sort(0x2208b60c08, 0x208f17660)
    /usr/src/go/src/pkg/sort/sort.go:200 +0x7b
main.sortHostListItemsByName(0x208f958c0, 0x8, 0x8)
    /go/src/github.com/docker/machine/commands.go:69 +0x268
main.cmdLs(0x208b82840)
    /go/src/github.com/docker/machine/commands.go:508 +0x7a1
github.com/codegangsta/cli.Command.Run(0x6ef5b0, 0x2, 0x0, 0x0, 0x703790, 0xd, 0x0, 0x0, 0x0, 0x0, ...)
    /go/src/github.com/docker/machine/Godeps/_workspace/src/github.com/codegangsta/cli/command.go:113 +0xeb2
github.com/codegangsta/cli.(*App).Run(0x208b3e000, 0x208b4c000, 0x2, 0x2, 0x0, 0x0)
    /go/src/github.com/docker/machine/Godeps/_workspace/src/github.com/codegangsta/cli/app.go:156 +0xaea
main.main()
    /go/src/github.com/docker/machine/main.go:67 +0x7cd

goroutine 19 [finalizer wait]:
runtime.park(0x2b4a0, 0xa5d8f8, 0xa5ba09)
    /usr/src/go/src/pkg/runtime/proc.c:1369 +0x89
runtime.parkunlock(0xa5d8f8, 0xa5ba09)
    /usr/src/go/src/pkg/runtime/proc.c:1385 +0x3b
runfinq()
    /usr/src/go/src/pkg/runtime/mgc0.c:2644 +0xcf
runtime.goexit()
    /usr/src/go/src/pkg/runtime/proc.c:1445

goroutine 20 [syscall]:
os/signal.loop()
    /usr/src/go/src/pkg/os/signal/signal_unix.go:21 +0x1e
created by os/signal.init·1
    /usr/src/go/src/pkg/os/signal/signal_unix.go:27 +0x32

goroutine 69 [select]:
net/http.(*persistConn).writeLoop(0x208b7e370)
    /usr/src/go/src/pkg/net/http/transport.go:885 +0x38f
created by net/http.(*Transport).dialConn
    /usr/src/go/src/pkg/net/http/transport.go:601 +0x957

goroutine 67 [select]:
net/http.(*persistConn).writeLoop(0x208b7e160)
    /usr/src/go/src/pkg/net/http/transport.go:885 +0x38f
created by net/http.(*Transport).dialConn
    /usr/src/go/src/pkg/net/http/transport.go:601 +0x957

goroutine 68 [IO wait]:
net.runtime_pollWait(0x2208b52410, 0x72, 0x0)
    /usr/src/go/src/pkg/runtime/netpoll.goc:146 +0x66
net.(*pollDesc).Wait(0x208b648b0, 0x72, 0x0, 0x0)
    /usr/src/go/src/pkg/net/fd_poll_runtime.go:84 +0x46
net.(*pollDesc).WaitRead(0x208b648b0, 0x0, 0x0)
    /usr/src/go/src/pkg/net/fd_poll_runtime.go:89 +0x42
net.(*netFD).Read(0x208b64850, 0x208bce000, 0x2000, 0x2000, 0x0, 0x2208b503f0, 0x23)
    /usr/src/go/src/pkg/net/fd_unix.go:242 +0x34c
net.(*conn).Read(0x208b7c3a8, 0x208bce000, 0x2000, 0x2000, 0x0, 0x0, 0x0)
    /usr/src/go/src/pkg/net/net.go:122 +0xe7
crypto/tls.(*block).readFromUntil(0x208c1fe60, 0x2208b52838, 0x208b7c3a8, 0x5, 0x0, 0x0)
    /usr/src/go/src/pkg/crypto/tls/conn.go:451 +0xd9
crypto/tls.(*Conn).readRecord(0x208c14000, 0x17, 0x0, 0x0)
    /usr/src/go/src/pkg/crypto/tls/conn.go:536 +0x1ff
crypto/tls.(*Conn).Read(0x208c14000, 0x208c8d000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
    /usr/src/go/src/pkg/crypto/tls/conn.go:901 +0x16a
net/http.noteEOFReader.Read(0x2208b60560, 0x208c14000, 0x208b7e3c8, 0x208c8d000, 0x1000, 0x1000, 0xa71900, 0x0, 0x0)
    /usr/src/go/src/pkg/net/http/transport.go:1203 +0x72
net/http.(*noteEOFReader).Read(0x208d29180, 0x208c8d000, 0x1000, 0x1000, 0x208b6b9b0, 0x0, 0x0)
    <autogenerated>:124 +0xca
bufio.(*Reader).fill(0x208f6d080)
    /usr/src/go/src/pkg/bufio/bufio.go:97 +0x1b3
bufio.(*Reader).Peek(0x208f6d080, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0)
    /usr/src/go/src/pkg/bufio/bufio.go:132 +0x101
net/http.(*persistConn).readLoop(0x208b7e370)
    /usr/src/go/src/pkg/net/http/transport.go:782 +0x95
created by net/http.(*Transport).dialConn
    /usr/src/go/src/pkg/net/http/transport.go:600 +0x93f

goroutine 66 [IO wait]:
net.runtime_pollWait(0x2208b522b0, 0x72, 0x0)
    /usr/src/go/src/pkg/runtime/netpoll.goc:146 +0x66
net.(*pollDesc).Wait(0x208b64990, 0x72, 0x0, 0x0)
    /usr/src/go/src/pkg/net/fd_poll_runtime.go:84 +0x46
net.(*pollDesc).WaitRead(0x208b64990, 0x0, 0x0)
    /usr/src/go/src/pkg/net/fd_poll_runtime.go:89 +0x42
net.(*netFD).Read(0x208b64930, 0x208bc8000, 0x2000, 0x2000, 0x0, 0x2208b503f0, 0x23)
    /usr/src/go/src/pkg/net/fd_unix.go:242 +0x34c
net.(*conn).Read(0x208b7c368, 0x208bc8000, 0x2000, 0x2000, 0x0, 0x0, 0x0)
    /usr/src/go/src/pkg/net/net.go:122 +0xe7
crypto/tls.(*block).readFromUntil(0x208c1fb30, 0x2208b52838, 0x208b7c368, 0x5, 0x0, 0x0)
    /usr/src/go/src/pkg/crypto/tls/conn.go:451 +0xd9
crypto/tls.(*Conn).readRecord(0x208b4f8c0, 0x17, 0x0, 0x0)
    /usr/src/go/src/pkg/crypto/tls/conn.go:536 +0x1ff
crypto/tls.(*Conn).Read(0x208b4f8c0, 0x208c83000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
    /usr/src/go/src/pkg/crypto/tls/conn.go:901 +0x16a
net/http.noteEOFReader.Read(0x2208b60560, 0x208b4f8c0, 0x208b7e1b8, 0x208c83000, 0x1000, 0x1000, 0xa71900, 0x0, 0x0)
    /usr/src/go/src/pkg/net/http/transport.go:1203 +0x72
net/http.(*noteEOFReader).Read(0x208d29080, 0x208c83000, 0x1000, 0x1000, 0x208b6b9a8, 0x0, 0x0)
    <autogenerated>:124 +0xca
bufio.(*Reader).fill(0x208f6cde0)
    /usr/src/go/src/pkg/bufio/bufio.go:97 +0x1b3
bufio.(*Reader).Peek(0x208f6cde0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0)
    /usr/src/go/src/pkg/bufio/bufio.go:132 +0x101
net/http.(*persistConn).readLoop(0x208b7e160)
    /usr/src/go/src/pkg/net/http/transport.go:782 +0x95
created by net/http.(*Transport).dialConn
    /usr/src/go/src/pkg/net/http/transport.go:600 +0x93f

goroutine 46 [sleep]:
time.Sleep(0x12a05f200)
    /usr/src/go/src/pkg/runtime/time.goc:39 +0x31
net.func·019()
    /usr/src/go/src/pkg/net/dnsclient_unix.go:183 +0x56
created by net.loadConfig
    /usr/src/go/src/pkg/net/dnsclient_unix.go:212 +0x153
$ 
$ docker-machine ls
NAME               ACTIVE   DRIVER       STATE     URL                         SWARM
amazonec2-03                amazonec2    Stopped                               
dev                         virtualbox   Running   tcp://192.168.99.100:2376   
dev2                        virtualbox   Running   tcp://192.168.99.101:2376   
ec2-swarm-01                amazonec2    Stopped                               ec2-swarm-master
ec2-swarm-02                amazonec2    Stopped                               ec2-swarm-master
ec2-swarm-03                amazonec2    Stopped                               ec2-swarm-master
ec2-swarm-master            amazonec2    Stopped                               ec2-swarm-master (master)
tomcat-2           *        virtualbox   Running   tcp://192.168.99.102:2376   

@ehazlett
Copy link
Contributor

@rossbachp thanks! that looks like it might be related to the new sorting. @ahmetalpbalkan any idea here?

@ahmetb
Copy link
Contributor

ahmetb commented Mar 19, 2015

@ehazlett ack. this comes from a corner case bug in the naturalsort library we hacked the other night. fix on the way.

@skarademir
Copy link

Fix is in. Pls ingest at your earliest convenience.

@ahmetb
Copy link
Contributor

ahmetb commented Mar 19, 2015

@ehazlett unfortunately godep is quite buggy for me every time I try. Can you please vendor the latest commit from the naturalsort repo?

@arun-gupta
Copy link

@ehazlett got a different error:

~/Downloads/docker-machine_darwin-amd64 create mydocker --virtualbox-boot2docker-url=file:///Users/arungupta/Downloads/boot2docker.iso --driver=virtualbox
INFO[0000] Creating CA: /Users/arungupta/.docker/machine/certs/ca.pem 
INFO[0000] Creating client certificate: /Users/arungupta/.docker/machine/certs/cert.pem 
INFO[0001] Downloading boot2docker.iso from file:///Users/arungupta/Downloads/boot2docker.iso... 
INFO[0001] Creating SSH key...                          
INFO[0002] Creating VirtualBox VM...                    
ERRO[0007] Error creating machine: exit status 1        
WARN[0007] You will want to check the provider to make sure the machine and associated resources were properly removed. 
FATA[0007] Error creating machine 

@ahmetb
Copy link
Contributor

ahmetb commented Mar 19, 2015

@arun-gupta can you add --debug flag right after machine command? @ehazlett in the exit code <> 0 cases drivers must print the stderr pipe without --debug, right? I am not sure what's the case but something similar is happening at the other issue regarding azure driver as well (exit status: 1, no message printed, we don't even know which cmd it was)

Maybe we should put the cmd's details next to the "exit status" error.

@rossbachp
Copy link
Author

@arun-gupta If you are sure that machine doesn't exists? If, remove it.

@ehazlett
Copy link
Contributor

@ahmetalpbalkan yeah unfortunately we do stuff with the output to not show debug -- maybe we can get something to change that on error.

@arun-gupta
Copy link

@ehazlett Removed ~/.docker, tried the command. Here is more detail with -D:

INFO[0001] Creating VirtualBox VM...                    
DEBU[0001] Creating 20000 MB hard disk image...         
Converting from raw image file="stdin" to file="/Users/arungupta/.docker/machine/machines/mydocker/disk.vmdk"...
Creating dynamic image with size 20971520000 bytes (20000MB)...
DEBU[0007] executing: /usr/bin/VBoxManage createvm --basefolder /Users/arungupta/.docker/machine/machines/mydocker --name mydocker --register 
DEBU[0007] STDOUT: Virtual machine 'mydocker' is created and registered.
UUID: 318397cd-2d84-4754-b92c-6f075acd52e3
Settings file: '/Users/arungupta/.docker/machine/machines/mydocker/mydocker/mydocker.vbox'

DEBU[0007] STDERR:                                      
DEBU[0007] executing: /usr/bin/VBoxManage modifyvm mydocker --firmware bios --bioslogofadein off --bioslogofadeout off --natdnshostresolver1 on --bioslogodisplaytime 0 --biosbootmenu disabled --ostype Linux26_64 --cpus 8 --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[0007] STDOUT:                                      
DEBU[0007] STDERR: VBoxManage: error: The machine 'mydocker' is already locked for a session (or being unlocked)
VBoxManage: error: Details: code VBOX_E_INVALID_OBJECT_STATE (0x80bb0007), component Machine, interface IMachine, callee nsISupports
VBoxManage: error: Context: "LockMachine(a->session, LockType_Write)" at line 471 of file VBoxManageModifyVM.cpp

ERRO[0007] Error creating machine: exit status 1        
WARN[0007] You will want to check the provider to make sure the machine and associated resources were properly removed. 
FATA[0007] Error creating machine                       

@ahmetb
Copy link
Contributor

ahmetb commented Mar 19, 2015

Yea vbox weirdness. Use a different machine name.

@arun-gupta
Copy link

@ahmetalpbalkan Cool, that worked like a charm.

@ehazlett When is this getting integrated in the trunk?

@ehazlett
Copy link
Contributor

@arun-gupta i'm working on the godeps now -- you said that fixed it?

@ahmetb
Copy link
Contributor

ahmetb commented Mar 19, 2015

@ehazlett can we make sure all cmd.Exec's print the output in case of exit status != 0 in all drivers

@arun-gupta
Copy link

@ehazlett Specifying a different machine name did fix it, yes!

@ehazlett
Copy link
Contributor

ah ok thanks!

@ahmetalpbalkan see #821 for the godep update / fix

tomeon pushed a commit to tomeon/machine that referenced this issue May 9, 2018
Reflow the README to 80 columns and update a few bits for better consistency
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
7 participants