際際滷

際際滷Share a Scribd company logo
bdehamer | CenturyLinkLabs
@bdehamer | @centurylinklabs
Docker for the
Rubyist
Brian DeHamer - CenturyLink Labs
Docker for the Rubyist
Overview
 Docker 101
 Ruby + Docker
 Rails + Docker
 Flatcar
Docker 101
 Portable packaging format and isolated
runtime environment for applications
 Lightweight virtualization*


Docker, what is it?
* Not really, but it's a useful starting point
guest OS
hardware
$
host OS
hypervisor
guest OS guest OS$ $
bins/libs
app 1
bins/libs
app 2
bins/libs
app 3
hardware
host OS
bins/libs
app 1
bins/libs
app 2
bins/libs
app 3
hardware
host OS
Docker Engine
bins/libs
app 1
bins/libs
app 2
bins/libs
app 3
Friendly Packaging of Existing Tech
namespaces - isolation of processes, networks, etc
cgroups - isolation of cpu, memory, etc
chroot - isolation of 鍖le system
unionfs - layered 鍖le system
Docker Ecosystem
Build
Image Format
Docker鍖le
docker build
Ship
Docker Hub
Private Registry
docker push /
docker pull
Run
Docker Engine
Docker Compose
docker run
Docker Remote API (REST)
Running Docker
 Linux
 [ apt-get | yum ] install docker-engine
 Docker-speci鍖c distros: CoreOS, RancherOS, etc
 OSX / Windows
 Requires a Linux VM
 boot2docker Docker Toolbox
*
Docker for the Rubyist
+
Of鍖cial OS Images
Image Name Size
fedora:21 241 MB
ubuntu:trusty 188 MB
debian:jessie 125 MB
alpine:3.2 5 MB
busybox:latest 2 MB
scratch 0 B
Of鍖cial Language Images
Image Name Size
rails:4.2 824 MB
ruby:2.2 717 MB
python:3.4 754 MB
node:0.12 706 MB
java:7-jdk 586 MB
golang:1.4 514 MB
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!
*
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)
Docker as Packaging for Ruby Apps
docker run myapp
vs
Ruby + OS libs + Bundler + Gems + myapp.rb
+
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
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
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
Flatcar
 Bootstrap new Rails + Docker projects
 Experimental gem
 Thin wrapper around rails new
 Generates docker-compose.yml for development
 Generates Dockerfiles for 鍖nal packaging
*
bdehamer | CenturyLinkLabs
@bdehamer | @centurylinklabs
Thanks!
Brian DeHamer - CenturyLink Labs

More Related Content

Docker for the Rubyist

  • 1. bdehamer | CenturyLinkLabs @bdehamer | @centurylinklabs Docker for the Rubyist Brian DeHamer - CenturyLink Labs
  • 3. Overview Docker 101 Ruby + Docker Rails + Docker Flatcar
  • 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
  • 6. guest OS hardware $ host OS hypervisor guest OS guest OS$ $ bins/libs app 1 bins/libs app 2 bins/libs app 3
  • 8. hardware host OS Docker Engine bins/libs app 1 bins/libs app 2 bins/libs app 3
  • 9. Friendly Packaging of Existing Tech namespaces - isolation of processes, networks, etc cgroups - isolation of cpu, memory, etc chroot - isolation of 鍖le system unionfs - layered 鍖le system
  • 10. Docker Ecosystem Build Image Format Docker鍖le docker build Ship Docker Hub Private Registry docker push / docker pull Run Docker Engine Docker Compose docker run Docker Remote API (REST)
  • 11. Running Docker Linux [ apt-get | yum ] install docker-engine Docker-speci鍖c distros: CoreOS, RancherOS, etc OSX / Windows Requires a Linux VM boot2docker Docker Toolbox *
  • 13. +
  • 14. Of鍖cial OS Images Image Name Size fedora:21 241 MB ubuntu:trusty 188 MB debian:jessie 125 MB alpine:3.2 5 MB busybox:latest 2 MB scratch 0 B
  • 15. Of鍖cial Language Images Image Name Size rails:4.2 824 MB ruby:2.2 717 MB python:3.4 754 MB node:0.12 706 MB java:7-jdk 586 MB golang:1.4 514 MB
  • 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
  • 19. +
  • 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 *
  • 24. bdehamer | CenturyLinkLabs @bdehamer | @centurylinklabs Thanks! Brian DeHamer - CenturyLink Labs