Fast Volume Sharing on Boot2Docker

When discussing docker with fellow developers on macs, I often hear complaints about boot2docker doesn’t work as expected, or how the performance of shared volumes is slow.

I hear their complaints, after all I hit my head more than once against the same problems. Eventually I found a sweet solution that works for me, and has been battle tested by my coworkers too, a setup based on parallels, vagrant and boot2docker.

Using parallels gives us a less bug ridden NFS implementation, needed to avoid the performance problems of shared folders.

We use vagrant to tie everything up and we get a nice fast boot2docker that is a bit less magic than the default one, but also less opaque.

Here’s my Vagrantfile, slightly tuned to also support the plain non-parallels boot2docker image.


Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| = "yungsang/boot2docker" "private_network", ip: ENV['BOOT2DOCKER_IP'] || ""

  config.vm.provider "parallels" do |v, override| = "parallels/boot2docker" "private_network", type: "dhcp"

  # http "forwarded_port", guest: 80, host: 80, auto_correct: true "forwarded_port", guest: 443, host: 443, auto_correct: true

  # rack "forwarded_port", guest: 9292, host: 9292, auto_correct: true

  config.vm.synced_folder "/Users/intinig/src", "/Users/intinig/src", type: "nfs", bsd__nfs_options: ["-maproot=0:0"], map_uid: 0, map_gid: 0
  config.vm.synced_folder "/Users/intinig/src", "/src", type: "nfs", bsd__nfs_options: ["-maproot=0:0"], map_uid: 0, map_gid: 0

The last two lines of the Vagrantfile are what allows us to run fast volume sharing. In this case, but you might want to adapt them to your needs, I share my ~/src folder as /src and as /Users/intinig/src on the boot2docker vm.

To start the boot2docker vm you just enter the folder where you have the Vagrantfile and launch vagrant up.

Let me know how it works for you, happy dockering!

Leave a Reply

Please Login to comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.