For those that aren’t up to speed – Vagrant now supports Docker as a Provider via plugin. If you are running on a system without native Docker support Vagrant will bootstrap a box that is native and proxy Docker commands into it. Rather slick if you ask me.
Problem is there appears to be a bug with a recent release of the vmware_fusion provider plugin which is breaking this functionality with VMware Fusion. By default the Docker provider uses a box hosted on Vagrant Cloud called mitchellh/boot2docker. This box is a lgithweight VM with an ISO mounted that is used to live boot. The bug has something to do with mucking up IDE/CDROM binding for Vmware Fusion VMX files. I didn’t dive into the bug for details.
I did search for workarounds and found some. But they were all a bit specific and fragile. Instead of using them I decided to use the built-in magic that Vagrant already provides with their Docker provider that allows you to select the box you want to use. So instead of using the currently broken mitchellh/boot2docker (on vmware_desktop) we will select a different box.
We need a box with native docker support. An Ubuntu box would serve nicely but you can use your flavor of distro. There is the option to choose a box with a built-in docker stack. I chose to use Vagrant’s Docker installer functionality to automatically install the latest Docker. This takes a little longer upfront but ensures I have the new hotness.
I uploaded my setup to Github here: https://github.com/lynxbat/boot2docker-fixie-example
The instruction from the README:
git clone email@example.com:lynxbat/boot2docker-fixie-example.git cd boot2docker-fixie-example/docker_container vagrant up
This will bring up the vagrant host VM (box-cutter/ubuntu1404), build a Docker image, and then run a container exposing port 80 and mapping to the host vm on port 8080. Then after the container comes up just run:
To open up the Apache2 default page in your browser (host_vm:8080). This is apache2 running in a container on top of your host VM. Hopefully this example helps someone else in getting Vagrant and VMware Fusion working again with Docker while the bug is being fixed.
PS – there is a weird bug where you get this:
Stderr: 2014/06/12 13:49:01 Get http:///var/run/docker.sock/v1.12/containers/json?all=1: dial unix /var/run/docker.sock: permission denied
If you run ‘vagrant up’ a second time it usually fixes itself.