Docker

3. September 2014

What is docker?

a toolset on top of linux containers (LXC)

With docker you can:

distributed applications

Main conceptual difference: docker aims to model processes!

What is a linux container?

Think VM...

© https://www.docker.com/whatisdocker/

What is a linux container?

...on a diet

© https://www.docker.com/whatisdocker/

Differences - the good parts

Differences - the bad parts

Building blocks: Images

Building blocks: Images

© http://docs.docker.com/terms/image/

Building blocks: Containers

Building blocks: Containers

© http://docs.docker.com/terms/container/

Bored already?

© http://www.cutestpaw.com/

What can I do?

How does it work?

The Dockerfile

FROM litaio/ruby
RUN apt-get update -qq && apt-get install -y ca-certificates
RUN gem install bundler
ADD . /root/app
WORKDIR /root/app
ENV HOME /root
RUN bundle install
EXPOSE 3000
ENTRYPOINT bundle exec unicorn -c config/unicorn.rb

The Docker Registry

→ this way ←

Demo

docker run base ping google.com
docker ps -a
docker images
docker run -p 7474:7474 --name 'neo4j' -d tpires/neo4j

Container links

(consumer) → (redis)
docker run --link neo4j:neo
--name="app" -d "the_app"
tcp_address = ENV['NEO_PORT_7474_TCP_ADDR']
port = ENV['NEO_PORT_7474_TCP_PORT']

Data volume container

(neo4j) → (neo4j-data-volume)

Dockerfile

VOLUME /data

Starting the container

docker run --name neo4j
--volumes-from neo4j-data-volume
-d neo4j:2.1.2

Multi-server: meet the ambassador pattern

(consumer) → (redis)
(consumer) → (redis-ambassador) → (redis)
(consumer) → (redis-ambassador) → ☁ → (redis-ambassador) → (redis)

Ambassador example

docker run -d --name redis_ambassador
--expose 6379 -e REDIS_PORT_6379_TCP=tcp://192.168.1.52:6379
svendowideit/ambassador

Security

LXC uses

Tools

The ecosystem is growing rapidly.

Here are some interesting projects.

Tools

Fig

Define and start your depent containers all in one.

web:
  build: .
  command: bundle exec unicorn -c config/unicorn.rb
  links:
   - memcached
  environment:
   - NEO_USER=neoadmin
memcached:
  image: borja/docker-memcached
  

Tools

Decentralized cluster management, failure handling and high availability.

Tools

CoreOS

Tools

Kubernetes

"Kubernetes is a system for managing containerized applications across multiple hosts, providing basic mechanisms for deployment, maintenance, and scaling of applications."

Tools

Self-hosted Heroku

Build your own infrastructure with a nice UI

Who's using it already?

Google, amazon, IBM, Microsoft, ebay, yandex, newrelic, mailgun, spotify, yelp, ...

You can run it with Red hat, ubuntu, OpenStack, VMWare, azure, EC2, google compute, ...

Questions?

Appendix

Building blocks: Images

Since Docker uses a Union File System, the processes think the whole file system is mounted read-write. But all the changes go to the top-most writeable layer, and underneath, the original file in the read-only image is unchanged. Since images don't change, images do not have state.