This document provides an overview of Docker for Ruby developers. It begins with a brief introduction to Docker, explaining how it provides portable packaging and isolated runtime environments for applications using lightweight virtualization. It then discusses how Ruby and Ruby on Rails applications can be packaged and run using Docker, including tips on base images, separating services into different containers, and using Docker for development. It also introduces Flatcar, an experimental Ruby gem for bootstrapping new Rails projects with Docker integration.
5. Portable packaging format and isolated
runtime environment for applications
Lightweight virtualization*
Docker, what is it?
* Not really, but it's a useful starting point
16. Smaller Ruby Images
centurylink/ruby-base
~350MB
Debian based
Tags available for Ruby 1.9, 2.0, 2.1, 2.2
Of鍖cial repo now has "slim" images
Use Alpine and roll your own!
*
17. Drive Docker via Ruby
*
Docker Remote API (REST / JSON)
All features exposed in Docker CLI available
Client libraries available for most languages
Ruby gem: docker-api (swipely/docker-api)
18. Docker as Packaging for Ruby Apps
docker run myapp
vs
Ruby + OS libs + Bundler + Gems + myapp.rb
20. Docker + Rails Tips
Choose your base image
rails (824 MB)
centurylink/ubuntu-rails (571 MB)
centurylink/debian-rails (517 MB)
centurylink/alpine-rails (475 MB)
Roll your own
21. Docker + Rails Tips
Embrace "One Service, One Container
Separate Rails and DB containers
Service discovery via container links and exposed
ports (at least for the simple cases)
link
DBWeb
EXPOSE 5432
22. Docker + Rails Tips
Use Docker for your dev environment
Alternative to RVM or rbenv?
Volume mount source code into the container
Use docker exec for rails, rake, bundle commands
Tie it all together with Docker Compose
23. Flatcar
Bootstrap new Rails + Docker projects
Experimental gem
Thin wrapper around rails new
Generates docker-compose.yml for development
Generates Dockerfiles for 鍖nal packaging
*