title: What's the right way to set up a development environment on OS X with Docker?
body: <h1>Intro</h1>
  
  <p>I can't figure out a good way to set up a development environment on OS X using Docker and Boot2Docker. The problem I'm hitting is how to manage the source code so that:</p>
  
  <ol>
  <li>I can modify the code on OS X using the tools (text editor, IDE, git, etc) I already have installed.</li>
  <li>Those modifications are reflected in the Docker container so if I re-run tests or refresh a webpage, I can see my changes immediately.</li>
  </ol>
  
  <p>In theory, this should be easy to do by mounting my source code as a volume:</p>
  
  <pre><code>docker run -it -v /path/to/my/source/code:/src some-docker-image
  </code></pre>
  
  <p>Unfortunately, this has two major issues that make it completely unusable on OS X:</p>
  
  <h1>Issue #1: Mounted volumes on VirtualBox (which use vboxsf) are extremely slow</h1>
  
  <p>For example, here is how long it takes Jekyll to compile my <a href="https://github.com/brikis98/yevgeniy-brikman-homepage" rel="nofollow noreferrer">homepage</a> if the source code is part of the Docker image:</p>
  
  <pre><code>&gt; docker run -it brikis98/yevgeniy-brikman-homepage:v1 bash
  
  root@7aaea30d98a1:/src# time bundle exec jekyll build
  
  [...]
  
  real    0m7.879s
  user    0m7.360s
  sys     0m0.600s
  </code></pre>
  
  <p>Here is the exact same Docker image, except this time, I mount the source code from OS X:</p>
  
  <pre><code>&gt; docker run -it -v $(pwd):/src brikis98/yevgeniy-brikman-homepage:v1 bash
  
  root@1521b0b4ce6a:/src# time bundle exec jekyll build
  
  [...]
  
  real    1m14.701s
  user    0m9.450s
  sys     0m3.410s
  </code></pre>
  
  <h1>Issue #2: File watching is broken</h1>
  
  <p>The default watch mechanisms in SBT, Jekyll, and grunt use technologies such as inotify, which do not work if they are running in a Docker container and the changes are made in OS X to a mounted folder.</p>
  
  <h1>Workarounds I tried</h1>
  
  <p>I searched for solutions (including all the ones on SO) and tried out a few of them, but have not found a successful one:</p>
  
  <ol>
  <li>I <a href="https://gist.github.com/neilbartley/73f2eb334f04bf95a906" rel="nofollow noreferrer">switched Boot2Docker to use NFS</a>, but it was just as slow.</li>
  <li>I tried <a href="https://stackoverflow.com/questions/28421391/whats-the-fastest-way-to-migrate-from-boot2docker-to-vagrantnfs-on-mac-os-x">Vagrant + NFS</a>, and that was also just as slow.</li>
  <li>I tried a <a href="http://www.slideshare.net/Docker/dockercon-beahappierdevwithdocker140613160957phpapp02-37589065" rel="nofollow noreferrer">Samba mount</a>, but the folder always showed up empty in the Docker container.</li>
  <li>I tried to use the <a href="https://github.com/leighmcculloch/docker-unison" rel="nofollow noreferrer">Unison file system</a>, which worked briefly to sync files, but then kept <a href="https://github.com/leighmcculloch/docker-unison/issues/2" rel="nofollow noreferrer">showing connection errors</a>.</li>
  <li>I enabled <a href="http://salizzar.net/2014/11/06/creating-a-github-jekyll-blog-using-docker/" rel="nofollow noreferrer">polling in Jekyll</a>, but that significantly increased the delay until my changes were picked up.</li>
  <li>I tried <a href="https://github.com/codekitchen/dinghy" rel="nofollow noreferrer">Dinghy</a>, a "faster, friendlier Docker on OS X with Vagrant" and got <em>some</em> improvement. Instead of Jekyll compilation being 10-15x slower, it was 2-3x slower. That's better, but still not quite usable.</li>
  </ol>
  
  <p>Has anyone found a solution that actually works and allows you to productively develop code with Docker and OS X?</p>
  
  <h1>Update: a solution at last!</h1>
  
  <p>I have finally found a solution that seems productive using Boot2Docker + rsync. I've captured the details on how to set this up in <a href="https://stackoverflow.com/questions/30090007/whats-the-right-way-to-setup-a-development-environment-on-os-x-with-docker#30111077">my own answer</a> as well as an open-source project called <a href="https://github.com/brikis98/docker-osx-dev" rel="nofollow noreferrer">docker-osx-dev</a>.</p>