boot2docker / boot2docker

DEPRECATED; see https://github.com/boot2docker/boot2docker/pull/1408
https://github.com/boot2docker/boot2docker/pull/1408
Apache License 2.0
8.33k stars 1.29k forks source link

don't use Port forwarding in v1.0.0 #395

Open gliush opened 10 years ago

gliush commented 10 years ago

I'm following this manual with slight changes

$ rm .boot2docker/boot2docker.iso
$ boot2docker delete
$ boot2docker init
2014/06/12 15:39:17 Creating VM boot2docker-vm...
2014/06/12 15:39:17 Apply interim patch to VM boot2docker-vm (https://www.virtualbox.org/ticket/12748)
2014/06/12 15:39:18 Setting NIC #1 to use NAT network...
2014/06/12 15:39:18 Port forwarding [ssh] tcp://127.0.0.1:2022 --> :22
2014/06/12 15:39:18 Port forwarding [docker] tcp://127.0.0.1:2375 --> :2375
2014/06/12 15:39:18 Setting NIC #2 to use host-only network "vboxnet0"...
2014/06/12 15:39:18 Setting VM storage...
2014/06/12 15:39:27 Done. Type `boot2docker up` to start the VM.
$ boot2docker up
2014/06/12 14:50:39 Waiting for VM to be started...
...........
2014/06/12 14:51:01 Started.
2014/06/12 14:51:01 Auto detection of the VM's IP address.
$ docker run -d -P training/webapp python app.py
$ docker port c6073a9fc281 5000
0.0.0.0:49153
curl localhost:49153
... hangs!!! 
$ boot2docker ssh "curl localhost:49153" 2>/dev/null
Hello world!
$ i=49153;
$ VBoxManage modifyvm "boot2docker-vm" --natpf1 "tcp-port$i,tcp,,$i,,$i";
$ VBoxManage modifyvm "boot2docker-vm" --natpf1 "udp-port$i,udp,,$i,,$i";

What should I do to make it work?

ps: MacOS 10.9.3

c4milo commented 10 years ago

I had the same issue and downloaded the new boot2docker management tool which fixed it: https://github.com/boot2docker/boot2docker-cli/releases/download/v1.0.0/boot2docker-v1.0.0-darwin-amd64

gliush commented 10 years ago

@c4milo here I described that usage, it didn't work for me either. Though, I built it from sources.

You used that binary to init and up vm the same way?

c4milo commented 10 years ago

Yes— Sent from Mailbox

On Thu, Jun 12, 2014 at 12:06 PM, Ivan Glushkov notifications@github.com wrote:

@c4milo here I described that usage, it didn't work for me either. Though, I built it from sources.

You used that binary to init and up vm the same way?

Reply to this email directly or view it on GitHub: https://github.com/boot2docker/boot2docker/issues/395#issuecomment-45912099

SvenDowideit commented 10 years ago

please. do not use the vbox port forwarding. use the host only IP address.

This will mean you need the new management tool, and to re-create your vm, but it avoids a stack of bugs in virtualbox.

gliush commented 10 years ago

@SvenDowideit thanks for the advice to avoid vbox :) you mean smth like: curl http://`boot2docker ip`/ ?

SvenDowideit commented 10 years ago

following on from the original example, you would

curl http://$(boot2docker ip):49153/
gliush commented 10 years ago

Sure, I mean the same. Thanks, Sven.

On Fri, Jun 13, 2014 at 2:36 PM, Sven Dowideit notifications@github.com wrote:

following on from the original example, you would

curl http://$(boot2docker ip):49153/

— Reply to this email directly or view it on GitHub https://github.com/boot2docker/boot2docker/issues/395#issuecomment-45997332 .

piclez commented 10 years ago

I just installed the new version 1.0 and after delete I get:

boot2docker init 2014/06/13 23:59:14 Downloading boot2docker ISO image... 2014/06/13 23:59:14 Latest release is v1.0.0 2014/06/13 23:59:25 Success: downloaded https://github.com/boot2docker/boot2docker/releases/download/v1.0.0/boot2docker.iso to /Users/peterwd/.boot2docker/boot2docker.iso 2014/06/13 23:59:25 Creating VM boot2docker-vm... 2014/06/13 23:59:25 Apply interim patch to VM boot2docker-vm (https://www.virtualbox.org/ticket/12748) 2014/06/13 23:59:25 Setting NIC #1 to use NAT network... 2014/06/13 23:59:25 Port forwarding [ssh] tcp://127.0.0.1:2022 --> :22 2014/06/13 23:59:25 Port forwarding [docker] tcp://127.0.0.1:2375 --> :2375 2014/06/13 23:59:26 Failed to create host-only network interface: exit status 2

boot2docker up 2014/06/13 23:59:44 Waiting for VM to be started... ............................. 2014/06/14 00:00:42 Started. 2014/06/14 00:00:42 Auto detection of the VM's IP address.

docker images 2014/06/14 00:02:15 Get http://127.0.0.1:2375/v1.12/images/json: EOF

Any ideas?

Thanks.

SvenDowideit commented 10 years ago

@piclez can you please 'boot2docker delete' again and then run 'boot2docker -v init'

If it fails again there should be more debug output that may help us debug

piclez commented 10 years ago

@SvenDowideit I ran that and this is what I get now:

executing: VBoxManage hostonlyif ipconfig dyld: DYLD_ environment variables being ignored because main executable (/Applications/VirtualBox.app/Contents/MacOS/VBoxNetAdp --ip 192.168.59.3 --netmask 255.255.255.0 The host network interface with the given name could not be found VBoxManage: error: Details: code NS_ERROR_INVALIDARG (0x80070057), component Host, interface IHost, callee nsISupports VBoxManage: error: Context: "FindHostNetworkInterfaceByName(name.raw(), hif.asOutParam())" at line 218 of file VBoxManageHostonly.cpp VBoxManage: error: Could not find interface 'dyld: DYLD environment variables being ignored because main executable (/Applications/VirtualBox.app/Contents/MacOS/VBoxNetAdp' 2014/06/14 09:57:07 Failed to create host-only network interface: exit status 2

I believe is something with VirtualBox. I remember I used a command one time to reload it with another similar problem. [I restarted VB and no luck]

Thanks!

henter commented 10 years ago

I had the same issue

SvenDowideit commented 10 years ago

@nathanleclaire - can you please write up your script findings as an FAQ?

nathanleclaire commented 10 years ago

@SvenDowideit You mean the script to unload and reload the kernel extensions? I can create a writeup on how to use it, however I'm not 100% sure it would help with the issues listed here.

@henter @piclez Are you able to open VirtualBox and see the VM running?

nathanleclaire commented 10 years ago

That being said:

sudo /Library/Application\ Support/VirtualBox/LaunchDaemons/VirtualBoxStartup.sh restart

has resolved Virtual Box issues in the past for me. But mine were related to Darwin kernel extensions misbehaving, and it looks like the issues mentioned by @piclez has to do with a misconfigured host-only network.

nathanleclaire commented 10 years ago

Followup: I just upgraded from an older version (0.11 I think) on my Mac laptop to 1.0, and I attempted to use the boot2docker installer. I rm -red $(which boot2docker) and ~/.boot2docker first before re-installing, but the installer bombed out (said that it failed) with no useful errors in the logs.

I still got the boot2docker binary installed on my system so I was able to run boot2docker status but it returned:

2014/06/19 10:08:25 Failed to get machine "boot2docker-vm": exit status 126

VirtualBox also wouldn't start up and gave me an error.

Running:

~$ sudo /Library/Application\ Support/VirtualBox/LaunchDaemons/VirtualBoxStartup.sh restart
Unloading VBoxUSB.kext
Unloading VBoxNetFlt.kext
Unloading VBoxNetAdp.kext
Unloading VBoxDrv.kext
/Applications/VirtualBox.app/Contents/MacOS/VBoxAutostart => /Applications/VirtualBox.app/Contents/MacOS/VBoxAutostart-amd64
/Applications/VirtualBox.app/Contents/MacOS/VBoxBalloonCtrl => /Applications/VirtualBox.app/Contents/MacOS/VBoxBalloonCtrl-amd64
/Applications/VirtualBox.app/Contents/MacOS/VBoxDD2GC.gc => /Applications/VirtualBox.app/Contents/MacOS/VBoxDD2GC.gc-amd64
/Applications/VirtualBox.app/Contents/MacOS/VBoxDDGC.gc => /Applications/VirtualBox.app/Contents/MacOS/VBoxDDGC.gc-amd64
/Applications/VirtualBox.app/Contents/MacOS/VBoxExtPackHelperApp => /Applications/VirtualBox.app/Contents/MacOS/VBoxExtPackHelperApp-amd64
/Applications/VirtualBox.app/Contents/MacOS/VBoxHeadless => /Applications/VirtualBox.app/Contents/MacOS/VBoxHeadless-amd64
/Applications/VirtualBox.app/Contents/MacOS/VBoxManage => /Applications/VirtualBox.app/Contents/MacOS/VBoxManage-amd64
/Applications/VirtualBox.app/Contents/MacOS/VBoxNetAdpCtl => /Applications/VirtualBox.app/Contents/MacOS/VBoxNetAdpCtl-amd64
/Applications/VirtualBox.app/Contents/MacOS/VBoxNetDHCP => /Applications/VirtualBox.app/Contents/MacOS/VBoxNetDHCP-amd64
/Applications/VirtualBox.app/Contents/MacOS/VBoxNetNAT => /Applications/VirtualBox.app/Contents/MacOS/VBoxNetNAT-amd64
/Applications/VirtualBox.app/Contents/MacOS/VBoxSVC => /Applications/VirtualBox.app/Contents/MacOS/VBoxSVC-amd64
/Applications/VirtualBox.app/Contents/MacOS/VBoxXPCOMIPCD => /Applications/VirtualBox.app/Contents/MacOS/VBoxXPCOMIPCD-amd64
/Applications/VirtualBox.app/Contents/MacOS/VMMGC.gc => /Applications/VirtualBox.app/Contents/MacOS/VMMGC.gc-amd64
/Applications/VirtualBox.app/Contents/MacOS/VirtualBox => /Applications/VirtualBox.app/Contents/MacOS/VirtualBox-amd64
/Applications/VirtualBox.app/Contents/MacOS/VirtualBoxVM => /Applications/VirtualBox.app/Contents/MacOS/VirtualBoxVM-amd64
/Applications/VirtualBox.app/Contents/MacOS/vboxwebsrv => /Applications/VirtualBox.app/Contents/MacOS/vboxwebsrv-amd64
Loading VBoxDrv.kext
Loading VBoxUSB.kext
Loading VBoxNetFlt.kext
Loading VBoxNetAdp.kext

Fixed VirtualBox (allowed it to start up without issue), and changed that message to:

~$ boot2docker status
2014/06/19 10:09:41 Failed to get machine "boot2docker-vm": machine does not exist

Which allowed me to resume the normal boot2docker init; boot2docker up; set DOCKER_HOST; run docker commands flow.

Not sure what's going on in all of these wide ranging error messages and issues.

SvenDowideit commented 10 years ago

essentially, when virtualbox breaks itself, boot2docker gets confused. I'm not 100% sure how many different error modes i can detect and deal with, but thankyou very much for the extra info

gracebrownecodes commented 10 years ago

@piclez I had the same problem as you and found a solution.

If you look closely at the output of boot2docker -v init in your comment, you can see that the dyld notice is somehow getting pulled into the command. The dyld notice is triggered when your bash config sets some DYLD_ variables, but the shell is initialized by a suid executable (you'll probably see the notice anytime you run sudo ... on your machine).

In my case, I had DYLD_ variables set up for the Oracle client on my machine. But regardless, you will need to find those variables and unset them before running initializing your boot2docker VM. I would suggest something like the following:

# If you type 'echo $DYLD_' and hit TAB, your particular 'DYLD_' var should autocomplete
$ echo $DYLD_LIBRARY_PATH
/usr/local/lib/instantclient_11_2:
# Obviously, substitute your particular var if its different
$ unset DYLD_LIBRARY_PATH
$ echo $DYLD_LIBRARY_PATH

$ boot2docker delete
$ boot2docker -v init
henter commented 10 years ago

@henter @piclez Are you able to open VirtualBox and see the VM running?

yes, the VM is running, but port forward is not working

SvenDowideit commented 10 years ago

@henter, which port forward isn't working - and do you really need it?

henter commented 10 years ago

@SvenDowideit , Hi I'm just try to run this demo on port 49160

thanks.

SvenDowideit commented 10 years ago

in that case, you really do not need vbox port forwarding - you can connect to that port on the ip address returned by boot2docker ip

henter commented 10 years ago

in that case, you really do not need vbox port forwarding - you can connect to that port on the ip address returned by boot2docker ip

can I forward port to docker from my mac ? like this: mac(41960) => boot2docker VM(41960) => docker(8080) ?

SvenDowideit commented 10 years ago

@henter, you can, but why would you want to?

whats more, if you ran your container using docker run -p 8080:8080 yourcontainer then you would be able to access it from your mac's browser with http://192.168.59.103:8080

borromeotlhs commented 10 years ago

I am trying to make multiple instance of a client that only runs, by default, on one port (9000), and use dockers -p port exposure methodology to start multiple clients at specific ports on the host machine. By what this issue states, at version 1.2.0, is this supposed to now work?

I seem to only be able to use one client at port 9000, and have no option but to use --net=host networking mode :(

jai11 commented 10 years ago

I , Actually I am facing a issue with docker. Looks like the same as discussed above.

I have installed jenkins on ubuntu:14.04 image

I am running the docker image with below command -

docker run -p 49153:8080 jai11/jenkins-run

Docker starts the jenkins process in it and I can access the jenkins through executing 192.168.59.103:49153 in my IE (windows)

What I want to know why it si not able to connect http://localhost:49153

I also tried to ping the container ID from my windows(CMD prompt) but its getting time out)

What is the expected behavior over here , also how can I connect from localhost.

Hoping a help from you.

Thanks ~Jai

dopry commented 9 years ago

@SvenDowideit, a note on use cases for the port forwarding. If you're working with TLS or any x.509 based PKI and STARTTLS and you've generated self-signed certs with a CN of localhost for development you do need to forward ports to localhost because https://{`boot2docker ip`}:{port}/ will not be localhost and the certificate will be rejected. Admittedly most people should generate properly named certificates for production, but boot2docker is a development tool and localhost is a pretty common CN when doing development. of course the work around is to just manually forward the ports in VirtualBox...