Vagrant is cool, but heavy. Can I use docker? Answer: Yes, with fig
Vagrant is cool, because it allows easy setup of development VMs to work in. But VMs tend to be quite heavy and running 20 services within 20 VMs on your Macbook will definitely keep you warm in the winter but may not help your productivity.
This is exactly where fig comes in: It allows you to configure a set of docker containers and their links between each other and then run each service within a docker container.
This is a very lightweight approach and it's perfectly fine to run 20 containers on your machine.
Docker and OSX: Boot2Docker and its problems
Now Docker is cool and all - but I know most of you are working on OSX. Often enough I'm doing that, too. But Docker is a Linuxcontainer tool. No OSX. Sad puppy.... but fear not!
Boot2Docker is a cool (and now recommended) way of getting Docker onto OSX: It starts a single, small VM to run Docker and the containers inside. Yay!
But there's bugs and road blocks...
The issue of fig, shared volumes and Boot2Docker
Unfortunately the way fig works (see their getting started guide, for example) is by sharing the directory containing your code with the docker container (mounting it as a volume). That works perfectly fine when you're on a Linux machine and Docker runs directly on it. But here, docker can only mount from the filesystem of your Boot2Docker VM.... which is not where your source code lives.
So here's the first hoop to jump - after installing boot2docker you should get a custom image for boot2docker that contains the guest additions of Virtualbox like this:
$ cd ~/.boot2docker $ curl http://static.dockerfiles.io/boot2docker-v1.0.0-virtualbox-guest-additions-v4.3.12.iso > .boot2docker.iso $ boot2docker init $ VBoxManage sharedfolder add boot2docker-vm -name home -hostpath /Users $ boot2docker up
(I found that solution after some googling at https://github.com/orchardup/fig/issues/26)
Once the machine is up, we need to mount the shared folder inside the VM:
$ boot2docker ssh "sudo modprobe vboxsf && mkdir -v -p /Users && sudo mount -v -t vboxsf -o uid=0,gid=0 home /Users"
That's a small variation from the issue thread I linked above: We're explicitely setting the uid and gid, so it becomes accessible.
The last pitfall: port forwarding
Care shall be taken with port forwards... the server you started is in another castle, Mario!
As "localhost" refers to the boot2docker VM, you have to use the private IP of the boot2docker VM and you get that from:
$ boot2docker ip