Related blog post:
http://artsy.github.io/blog/2015/12/09/docker-for-development/
Reasons for using docker:
- new developers have a setup that works without installing and configuring MongoDB, Solr, Elasticsearch, memcached, etc.
- a
docker-compose.yml
file can provide the related services and environment variables an application needs.
Docker Toolbox
https://docs.docker.com/mac/step_one/
This will install a default machine, which you will want to remove if you want more disk space (likely) or RAM. You also don't need it if you use Dusty or Dinghy.
Or Homebrew
brew install docker docker-machine
We started by using the standard Docker tools, but the shared folder performance was so bad for the default VM provider (VirtualBox) that we investigated Dusty (which provides NFS), but I have now switched to Dinghy for my development.
For better performance try Dinghy:
https://github.com/codekitchen/dinghy
For a large rails app, our test and app startup time dropped by at least 50%.
Sets up a boot2docker VM since it can't run natively on OS X.
# remove the default one created by Docker Toolbox
docker-machine rm default
# with standard VirtualBox setup
docker-machine create -d virtualbox --virtualbox-disk-size 25000 --virtualbox-memory 6000 dusty
# with Dinghy
dinghy create --provider virtualbox -m 6000 -d 25000
# add this to your shell startup (.zshrc, etc.)
eval "$(docker-machine env dinghy)"
# I recommend adding the docker host to /etc/hosts
echo "$(docker-machine ip dinghy) docker" | sudo tee -a /etc/hosts
- run Redis in docker:
docker run --name redis -d -p 6379:6379 redis
- Dockerfile, docker-compose and common.yml with our main API
docker-compose up
docker-compose ps
docker-compose logs sidekiq
docker-compose run web bash
docker-compose run web rake db:create:users #ephemeral container
- Run this on a machine with at least 8GB or RAM, preferably 16+GB
- If your apps do an OAuth redirect, you need to use the same port on your containers that are mapped to your Docker host VM. We had to set it up so our main API used port 80 in its container and for the Docker host.
- If you use dinghy and want to map to port 80, you have to disable their nginx proxy:
dinghy up --no-proxy