Ruby in Docker



Ruby in Docker

0 0


prug-docker


On Github tiokksar / prug-docker

Ruby in Docker

PRUG November 2013

Tomasz Tokarski

Linux container engine

Created to pack, ship, and run any app as a lightweight, portable, self-sufficient container.

Initially released March 2013

Currently in 0.7 version.

Written in Go

by Docker Inc. (formerly Dotcloud)

Apache License 2.0

Architecture

LXC

Linux Containers

Provides a lightweight virtualization that runs processes in isolation. Based on cgroups & Linux kernel features.

Containers does not include separate operating system.

Production ready

Heroku stack is based on the project.

version 1.0 Scheduled for February 2014 ;-)

CGroups

  • Control Groups
  • Kernel 2.6.24
  • Process group management

AUFS

  • AnotherUnionFS
  • Used for creating file system layers.
  • Supports copy-on-write.

So basically:

chroot < docker < virtual machines

Why do I need all that stuff?

Conventions

Operations

  • RUN
  • START
  • STOP
  • RESTART
  • KILL
  • RM

One process per containter

WAT ? One process per containter ???

Actually one process group.

Networking

By default Docker creates docker0 bridge

Before a container starts, Docker will allocate an IP address in the pool, and setup a virtual ethernet interface for the container

You can specify open ports.

You can map ports from host system to container.

When a container stops, the IP address is given back to the pool, ports are also released.

IPv4 only

Sharing filesystem between host and containter.

Configuration

You can inject ENV variables into containers.

Interacting containers

You can link containers using syntax:

-link container_name_mongo:mongo

ENV variables set to current values: MONGO_PORT_27017_TCP_ADDR MONGO_PORT_27017_TCP_PORT

How do I create a container?

Maybe You don't have to.

Docker Index contains thousands of community created container images.

Most of them are experiments.

Docker Index

Two new features.

Stars

Trusted builds.

How to create a containter?

Manually changing a container and committing the changes. Using Dockerfile

Using existing tools

Chef solo Berkshelf

Example Dockerfile

FROM stackbrew/ubuntu:saucy
MAINTAINER Tomasz Tokarski tomasz@tomasztokarski.com
RUN apt-get update
RUN apt-get install -y ruby2.0 ruby2.0-dev git curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev
RUN gem install bundler -v 1.5.0.rc.1 --no-ri --no-rdoc
RUN gem install berkshelf-solo --no-ri --no-rdoc
ADD Gemfile /Gemfile
ADD Gemfile.lock /Gemfile.lock
RUN bundle -j 8
ADD Berksfile /Berksfile
ADD node.json /node.json
ADD solo.rb /solo.rb
RUN berks vendor
RUN chef-solo -c solo.rb -j node.json
RUN npm install -g karma
RUN npm install -g coffee-script
RUN npm install -g karma-coffee-preprocessor
CMD ["start", "/karma/karma.js"]
ENTRYPOINT ["karma"]
          

See the repo at github.com/tiokksar/docker-karma

Bad news/Problems of Adolescence

not production ready yet API can change Update problems Linux Only(a new one, a 64 bit one) Bugs

THE END

by Tomasz Tokarski