Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@bhoggard
Last active February 10, 2016 11:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bhoggard/5987d92db297bbd85e13 to your computer and use it in GitHub Desktop.
Save bhoggard/5987d92db297bbd85e13 to your computer and use it in GitHub Desktop.

Rent The Runway - Docker D&D

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%.

Creating a docker machine

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

Examples

  • 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

Gotchas

  • 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment