fnichol / dvm

An on demand Docker virtual machine, thanks to Vagrant and boot2docker. Works great on Macs and other platforms that don't natively support the Docker daemon. Support VirtualBox, VMware, and Parallels.
http://fnichol.github.io/dvm
Apache License 2.0
458 stars 71 forks source link

dvm ssh works but cant run docker commands #9

Closed wickett closed 10 years ago

wickett commented 10 years ago

Installation seemed to go ok, and I can run dvm ssh and get connected to the virtual machine and am greeted with the boot2docker MOTD and pompt. However when I try to run docker commands this is what happens

$ docker run ubuntu cat /etc/passwd
2014/01/16 10:51:42 dial tcp 192.168.42.43:4243: operation timed out

and if I try to sudo it

$ sudo docker run ubuntu cat /etc/passwd
2014/01/16 10:52:51 dial unix /var/run/docker.sock: no such file or directory

I am sure I jacked something up here, but not sure what. The docker.sock doesnt appear to be there. Any ideas?

patrickkettner commented 10 years ago

Believe this is expected

from the readme...

Your local docker binary needs to be told that it is targetting a remote system and to not try the local Unix socket, which is the default behavior. Version 0.7.3 of Docker introduced the DOCKER_HOST environment variable that will set the target Docker host. By default, dvm will run your VM on a private network at 192.168.42.43 with Docker listening on port 4243. The dvm env subcommand will print a suitable DOCKER_HOST line that can be used in your environment. If you want this loaded into your session, evaluate the resulting config with:

$ echo $DOCKER_HOST

$ eval `dvm env`

$ echo $DOCKER_HOST tcp://192.168.42.43:4243

corporate-gadfly commented 10 years ago

$ eval dvm env

that got botched by the GFM. An equivalent command is:

eval $(dvm env)

or (using backticks):

eval `dvm env`
patrickkettner commented 10 years ago

ah, good eye. updated

thanks @corporate-gadfly

wickett commented 10 years ago

DOCKER_HOST looks set ok

$ echo $DOCKER_HOST tcp://192.168.42.43:4243

Still not working.

On Thu, Jan 16, 2014 at 11:18 AM, patrick kettner notifications@github.comwrote:

Believe this is expected

from the readme...

Your local docker binary needs to be told that it is targetting a remote system and to not try the local Unix socket, which is the default behavior. Version 0.7.3 of Docker introduced the DOCKER_HOST environment variable that will set the target Docker host. By default, dvm will run your VM on a private network at 192.168.42.43 with Docker listening on port 4243. The dvm env subcommand will print a suitable DOCKER_HOST line that can be used in your environment. If you want this loaded into your session, evaluate the resulting config with:

$ echo $DOCKER_HOST

$ eval dvm env

$ echo $DOCKER_HOST tcp://192.168.42.43:4243

— Reply to this email directly or view it on GitHubhttps://github.com/fnichol/dvm/issues/9#issuecomment-32490049 .

corporate-gadfly commented 10 years ago

However when I try to run docker commands this is what happens

Silly question, but you are running docker commands from OSX terminal, right?

Following sequence should work:

dvm up
eval $(dvm env)
docker run ubuntu cat /etc/lsb-release
patrickkettner commented 10 years ago

shoot, i'm sorry. I was completely wrong. your err specifically says connecting to the IP. Too early for me. try dvm ssh to connect to the vm, run ifconfig eth1 to verify the IP address. Assuming it is 192.168.42.43, check your virtualbox networking options to make sure the networking isn't host only or anything

wickett commented 10 years ago

@corporate-gadfly yeah I am running it from OS X. When I dvm ssh and run ifconfig it shows that eth1 is 192.168.42.43 and a netstat -anlp shows port 4243 is LISTENING. Weird that it doesnt connect right?

Virtual Box shows that it is set up as NAT...

patrickkettner commented 10 years ago

what does curl http://192.168.42.43:4243 from the host machine produce?

fnichol commented 10 years ago

@wickett You can also be explicit when connecting to a docker host with docker -H tcp://192.168.42.43:4243 version. This would try to hit dvm's docker daemon to get its version info as well. @corporate-gadfly is correct with the dvm env subcommand--I wanted a quick a dirty way to display or set the $DOCKER_HOST environment variable which Docker 0.7.1 and up honor.

wickett commented 10 years ago

So, this may have been a transient error. Before getting started with dvm, I upgraded virtualbox, upgraded vagrant and then installed dvm. I never did a reboot.

When I opened up VirtualBox to look at the network adapters a couple of the menu items under 'promiscuous' were toggling back forth without me doing anything to them. Looked really weird and made me decide I better reboot this thing before I go much further.

After a system reboot, it appears to be working. So, I guess we can close this, although it might be worth noting on the README that if you are just upgrading VirtualBox then a reboot might be in order.

@patrickkettner @corporate-gadfly @fnichol thanks for your help. Stoked to use dvm, thanks for creating it.

lvnilesh commented 10 years ago

I rebooted as well. still no joy.

➜  ~  dvm up
Bringing machine 'dvm' up with 'virtualbox' provider...
[dvm] Importing base box 'boot2docker-0.4.0'...
[dvm] Matching MAC address for NAT networking...
[dvm] Setting the name of the VM...
[dvm] Clearing any previously set forwarded ports...
[dvm] Clearing any previously set network interfaces...
[dvm] Preparing network interfaces based on configuration...
[dvm] Forwarding ports...
[dvm] -- 22 => 2222 (adapter 1)
[dvm] Running 'pre-boot' VM customizations...
[dvm] Booting VM...
[dvm] Waiting for machine to boot. This may take a few minutes...
[dvm] Machine booted and ready!
[dvm] No guest additions were detected on the base box for this VM! Guest
additions are required for forwarded ports, shared folders, host only
networking, and more. If SSH fails on this machine, please install
the guest additions and repackage the box to continue.

This is not an error message; everything may continue to work properly,
in which case you may ignore this message.
[dvm] Configuring and enabling network interfaces...
[dvm] Running provisioner: shell...
[dvm] Running: inline script
boot2docker: 0.4.0
➜  ~  eval $(dvm env)
➜  ~  docker info
2014/02/07 21:19:06 Error :Not Found

➜  ~  dvm ssh
                        ##        .
                  ## ## ##       ==
               ## ## ## ##      ===
           /""""""""""""""""\___/ ===
      ~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ /  ===- ~~~
           \______ o          __/
             \    \        __/
              \____\______/
 _                 _   ____     _            _
| |__   ___   ___ | |_|___ \ __| | ___   ___| | _____ _ __
| '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__|
| |_) | (_) | (_) | |_ / __/ (_| | (_) | (__|   <  __/ |
|_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_|
boot2docker: 0.4.0
docker@boot2docker:~$ ifconfig eth1
eth1      Link encap:Ethernet  HWaddr 08:00:27:0F:92:18  
          inet addr:192.168.42.43  Bcast:192.168.42.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe0f:9218/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:13 errors:0 dropped:0 overruns:0 frame:0
          TX packets:23 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:2658 (2.5 KiB)  TX bytes:2423 (2.3 KiB)

docker@boot2docker:~$ Connection to 127.0.0.1 closed.
➜  ~  docker -H tcp://192.168.42.43:4243 version
Client version: 0.8.0
Go version (client): go1.2
Git commit (client): cc3a8c8
2014/02/07 21:22:00 Error :Not Found
➜  ~  
endersonmaia commented 10 years ago

Same error here!

➜  ~  docker -H $DOCKER_HOST version
Client version: 0.8.0
Go version (client): go1.2
Git commit (client): cc3a8c8d8ec57e15b7b7316797132d770408ab1a
2014/02/11 21:53:21 Error :Not Found
lvnilesh commented 10 years ago

Can't reopen this closed issue. Appreciate if @fnichol & @wickett would please take a look. Thank you.

lvnilesh commented 10 years ago

Thank you @fnichol for updates that resolved the issue.

➜ ~ docker run ubuntu cat /etc/lsb-release Unable to find image 'ubuntu' (tag: latest) locally Pulling repository ubuntu 9f676bd305a4: Download complete 9cd978db300e: Download complete eb601b8965b8: Download complete 5ac751e8d623: Download complete 9cc9ea5ea540: Download complete 511136ea3c5a: Download complete 1c7f181e78b9: Download complete 321f7f4200f4: Download complete f323cf34fd77: Download complete 7a4f87241845: Download complete 6170bb7b0ad1: Download complete DISTRIB_ID=Ubuntu DISTRIB_RELEASE=12.04 DISTRIB_CODENAME=precise DISTRIB_DESCRIPTION="Ubuntu 12.04 LTS"