6

I have a database container built from the official mysql docker pull mysql.

I have a front-end app app built with Cake.

I have a back-end app cms built with Symfony.

I have container linking set up for both app and cms to start and connect automatically to db.

Everything works great but it's super slow with boot2docker.

I've been trying to understand how to use Vagrant with NFS.

There's a few different tutorials and examples online, but so far I've been unable to get going. I have installed the latest Vagrant and used the example yungsang/boot2docker but when I try the simplest command docker images I keep getting errors like FATA[0000] An error occurred trying to connect: Get https://localhost:2375/v1.16/images/json: tls: oversized record received with length 20527.

I discovered that if I vagrant ssh into the VM, I can run docker images and such, but that's not what I wanted; I am used to running docker commands straight from the Mac OS X terminal. So clearly I've misunderstood something. Also the tutorials on the Vagrant blog use rsync and --provider=docker which also doesn't seem necessary to use the yungsang/boot2docker vagrant box.

I would be grateful for some guidance and feel like I exhausted my Google search capabilities on this one.

Refs:

https://www.vagrantup.com/blog/feature-preview-vagrant-1-6-docker-dev-environments.html https://github.com/boot2docker/boot2docker/issues/64 https://vagrantcloud.com/yungsang/boxes/boot2docker

phpguru
  • 2,351
  • 2
  • 23
  • 33
  • Also helpful: http://www.reddit.com/r/docker/comments/2osgl7/vagrant_vs_boot2docker/ with sample Vagrant file http://dumptext.com/vKgOkYFF – phpguru Feb 10 '15 at 20:02

1 Answers1

17

Update [2015-02-11]

To answer the broader question (the one in the title) I've created a repo on Github with a Vagrantfile which will let you start with Vagrant+Docker+NFS on MacOS quickly and easily.

https://github.com/blinkreaction/boot2docker-vagrant


Original answer to the "tls: oversized record received" issue [2015-02-10]

The issue

Check your environment variables. You most likely have a mix of boot2docker shellinit and your custom DOCKER_HOST variables there. E.g.:

$ env|grep DOCKER

DOCKER_HOST=tcp://localhost:2375
DOCKER_CERT_PATH=/Users/<user>/.boot2docker/certs/boot2docker-vm
DOCKER_TLS_VERIFY=1

The reason you got here is first $(boot2docker shellinit) exported something like this to point the docker client to the boot2docker VM:

DOCKER_HOST=tcp://192.168.59.103:2376
DOCKER_CERT_PATH=/Users/<user>/.boot2docker/certs/boot2docker-vm
DOCKER_TLS_VERIFY=1

Then you pointed your docker client to the custom VM mapped port with

export DOCKER_HOST=tcp://localhost:2375

How to fix

Short term

unset DOCKER_TLS_VERIFY

Long term

Either get rid of the $(boot2docker shellinit) in your .bashrc, .zshrc, etc. file and execute it manually when needed or have it in the following order there:

# Docker (default for Vagrant based boxes)
export DOCKER_HOST=tcp://localhost:2375

# boot2docker shellinit
$(boot2docker shellinit)

This way if boot2docker is NOT running, your DOCKER_HOST will default to tcp://localhost:2375.
Otherwise $(boot2docker shellinit) will overwrite the variables and set DOCKER_HOST to point to the boot2docker VM.

Leonid Makarov
  • 1,118
  • 8
  • 8
  • Awesome, that worked... well, I can run docker ps -a but my same docker run command that I've been using for `db` fails with: FATA[0000] Error response from daemon: No command specified – phpguru Feb 10 '15 at 17:22
  • Thanks for the Vagrantfile on Github. Do you use config.vm.provision :docker do |d| in your Vagrantfile? I ask because thus far I have a blank Vagrantbox running the yungsang/boot2docker image, but I cannot use any docker run commands to actually get containers & apps running inside it. – phpguru Feb 12 '15 at 20:25
  • $ vagrant up $ export DOCKER_HOST=tcp://localhost:2375 $ docker version Does the last command give you and error or shows docker version info? If it does not fail, then you should be able to run your docker stuff. – Leonid Makarov Feb 13 '15 at 22:34
  • note that as of docker 1.91a on windows with a default setup, my environment variables are: `DOCKER_HOST=tcp://192.168.99.100:2376` and `DOCKER_CERT_PATH=%USERPROFILE%\.docker\machine\certs`. COnfigure those within the windows system properties and it works all the time. – Alex C Nov 26 '15 at 16:45