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
Docker for Mac and Windows shall be the definitive way of developing with Docker on OS X (and Windows). A Docker product, the software is an “integrated, easy-to-deploy environment for building, assembling, and shipping applications from Mac or Windows.” It purports to be able to solve the issues presented by the OP. From its March 24, 2016 announcement:
I've been developing in a OS X (mid 2011 Macbook Air) + Boot2Docker + Docker-compose environment for a few weeks now. Haven't run into major performance issues but I avoid running any sort of build when developing (why not use something like jekyll serve --skip-initial-build
?). Here's an example docker-compose.yml
file I'm using:
docker-compose.yml:
test:
build: .
volumes:
- ./client:/src/client
- ./server:/src/server
- ./test:/src/test
command: nodemon --exec jasmine-node -- test/ --verbose --autotest --captureExceptions --color
environment:
- DEBUG=*
Dockerfile:
FROM node:0.12
RUN mkdir -p /src
WORKDIR /src
ENV PATH=/src/node_modules/.bin:$PATH
# We add package.json first so that we the
# image build can use the cache as long as the
# contents of package.json hasn't changed.
COPY package.json /src/
RUN npm install --unsafe-perm
COPY . /src
CMD [ "npm", "start" ]
EXPOSE 3000
I sometimes use NFS (http://syskall.com/using-boot2docker-using-nfs-instead-of-vboxsf/) but haven't noticed a big performance difference when doing so.
For me, the convenience of a simple docker-compose up test
to get my environment running has been worth the cost in performance (I routinely work on multiple projects with different stacks).
PS: nodemon
is one of the few file watchers which work with vboxsf (see https://github.com/remy/nodemon/issues/419).
I'm also using Vagrant with parallels and boot2docker (https://github.com/Parallels/boot2docker-vagrant-box). Development was never easier for me. Works really well with docker-compose
and large setups. I don't really feel a delay or massive resource consumption.
This is what my Vagrantfile
looks like:
Vagrant.configure(2) do |config|
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.box = "parallels/boot2docker"
config.vm.synced_folder "/Users", "/Users", type: "nfs", mount_options: ["nolock", "vers=3", "udp"], id: "nfs-sync"
end
Disclaimer: I might be biased, since I am the author of docker-sync.
I probably tried all the solutions named here, including some more (see the compersion https://github.com/EugenMayer/docker-sync/wiki/Alternatives-to-docker-sync), but they basically either failed on the side of performance (most of them) or on the docker-machine (or none) used / enforced.
http://docker-sync.io has been built to merge all the solutions and provide the best strategies (implementing several, you can choose).
It can be used with rsync (1 way sync) including permission fixes for users, and with unison (2 way sync). It does neither force you into docker-machine or a specific hypervisor, nor requires you to have docker for Mac. It works with all of them.
The performance EugenMayer/docker-sync/wiki/4.-Performance is not influenced, it's like you have no shares at all.
docker-sync and its change-watchers are optimized and do work with projects with 12k files without issues.
Give it a try, if you like, I would love to hear feedback!