Why Docker? Because it promises to make dev-ops easier. Dockerizing an existing production environment is not trivial, moving development to Docker is perhaps a useful stepping stone. It might also make developer on-boarding easier but I haven’t tried that yet.
Docker can be installed on OS X in various ways, most notably Docker Toolbox or homebrew. I was previously using docker-machine with Parallels but recently I discovered Dlite which simplifies using docker by creating a local OS X docker.sock that forwards requests to the docker VM. Dlite also sets up a an NFS server that exports /Users to the VM. Instead of VirtualBox or Parallels Dlite leverages a lightweight hypervisor called xhyve which requires Yosemite and hardware virtualization support (sysctl kern.hv_support). Note that as of writing Docker for Mac and Windows in public beta is using a similar approach.
With Dlite started I can get a usable bash session with:
docker run -v /Users:/home -it ruby:2.2 bash
I can then cd to the project directory and bundle.
To run browser based tests I was previously building a docker image with Xvfb, Chrome and Selenium Server installed. Recently, however, I found a different approach that uses standalone selenium-server as another docker service. On a Mac workstation installing selenium-server as a service is as simple as
brew install selenium-server-standalone chromedriver
Once tests are passing with a local selenium-server then adding selenium/standalone-chrome to docker-compose.yml and running browser based tests inside the container is quite achievable. The location of the selenium-server is exported to the app container as SELENIUM_PORT, eg. tcp://220.127.116.11:4444