Download - Docker Introduction

Transcript
Page 1: Docker Introduction
Page 2: Docker Introduction

Who I am?

• Robert Reiz

• Software Developer

• I started VersionEye

• I’m NOT your IT guy!

• I don’t want to deal with IT !

Page 3: Docker Introduction

Shipment without

Containers

Page 4: Docker Introduction

1956 Malcom McLean introduced the 40’Container - ISO 668.

> 15 Million inst.

2/3 of global trade run over 40’Containers!

Page 5: Docker Introduction

The Logistic Problem

Page 6: Docker Introduction
Page 7: Docker Introduction
Page 8: Docker Introduction

Same Problem in Software Dev.

Page 9: Docker Introduction

Java ? ? ?

Ruby ? ? ?

MySQL ? ? ?

Memcached ? ? ?

Dev-Env. Test-Env. Prod-Env.

Page 10: Docker Introduction

Java JKD 1.6.34 - Win32 JKD 1.6.1 - Lnx-64 JDK 1.6-patch UNX

Ruby 2.1.1 rvm 2.1.1 nat 2.1.0 rubinius

MySQL 5.5 win 5.0 Linux 5.0 Linux

Memcached 1.4.14 1.4.0 1.4.10

Dev-Env. Test-Env. Prod-Env.

Page 11: Docker Introduction

Java

Ruby

MySQL

Memcached

Dev-Env. Test-Env. Prod-Env.

Page 12: Docker Introduction

What is Docker?

❖ Open Source Project started in March 2013 ❖ From the makes of dotCloud (PaaS). ❖ Received $55 Million Funding. ❖ Community grows rapidly!

Page 13: Docker Introduction

What is Docker?

❖ Tiny VM (25 MB) ❖ Linux based - LXC Interface / libcontainer ❖ Own Namespaces and Cgroups! ❖ Shared resources with host system. ❖ It doesn’t work on Windows!

Page 14: Docker Introduction

Build - Ship - Run

Docker-Hub

Build RUN

RUN

RUN

docker pushdocker pull

Server Farm Production

Page 15: Docker Introduction

Build

Page 16: Docker Introduction

Build - DockerfileFROM ubuntu:14.10 MAINTAINER Robert Reiz <[email protected]> !ENV LANG en_US.UTF-8 !RUN apt-get update RUN apt-get install -y --force-yes -q nginx !ADD nginx.conf /etc/nginx/nginx.conf !CMD nginx !EXPOSE 80

Page 17: Docker Introduction

Build - Dockerfile

> docker build -t reiz/nginx:1.0.0 .

docker image => reiz/nginx:1.0.0

Page 18: Docker Introduction

Ship

Page 19: Docker Introduction

Ship Docker Image

> docker push reiz/nginx:1.0.0

Page 20: Docker Introduction

Run

Page 21: Docker Introduction

Fetch a Docker Image

> docker pull reiz/nginx:1.0.0

Download docker image reiz/nginx:1.0.0 from Docker Hub to local Docker repository.

Page 22: Docker Introduction

Run a Docker Container

> docker run reiz/nginx:1.0.0

Creates a Docker container out of the Docker image reiz/nginx:1.0.0. It runs the nginx process.

Page 23: Docker Introduction

More Commands

> docker stop <container_id>> docker start <container_id>> docker top <container_id>> docker logs <container_id>> docker rm <container_id>

Page 24: Docker Introduction

Important

❖ A Docker Container doesn’t store state! ❖ You can not ssh into a Docker Container! ❖ A container is supposed to run 1 process!

Page 25: Docker Introduction

Shell

Page 26: Docker Introduction

Get a Shell

> docker run -i -t reiz/mongodb:1.0.2 /bin/bash

Starts a new Docker container with an active shell.

Page 27: Docker Introduction

Volumes

Page 28: Docker Introduction

Mount a Volume

> docker run -v /mnt/mongodb:/data -d reiz/mongodb:1.0.2

Mounts “/mnt/mongodb” directory into the Docker container as “/data”.

Page 29: Docker Introduction

Environment Variables

Page 30: Docker Introduction

Set environment variables

> docker run --env LANG=en_US.UTF-8 -d reiz/mongodb:1.0.2

Page 31: Docker Introduction

Links

Page 32: Docker Introduction

Link Docker Containers

> docker run —name mongodb -d reiz/mongodb:1.0.2 > docker run —link mongodb:mongo veye/app:1.0.0

MONGO_PORT=tcp://172.1.10.1:27017 MONGO_PORT_27017_TCP=tcp://172.1.10.1:27017 MONGO_PORT_27017_TCP_ADDR=172.1.10.1 MONGO_PORT_27017_TCP_PORT=27017 MONGO_PORT_27017_TCP_PROTO=tcp

Environment variables are injected in 2nd container:

Page 33: Docker Introduction

Link Docker Containers

Linking only works on same hosts!

Page 34: Docker Introduction

Service Discovery

Page 35: Docker Introduction

Service Discovery

❖ Environment Variables ❖ Mount configuration via volumes ❖ Linking ❖ Use a service like: etcd, zookeeper etc…

Page 36: Docker Introduction

Orchestration

Page 37: Docker Introduction

Docker Orchestration

❖ CM-Tools (Chef, Puppet, Ansible, Salt) ❖ https://flynn.io/ ❖ https://www.openshift.com/

Page 38: Docker Introduction

Real World Use case

Page 39: Docker Introduction

WWW

API

APP

APP

RabbitMQ

Tasks

MongoDB MongoDB MongoDB

Elastic Search

MemcachedCrawlers

x N

VersionEye Infrastructure

Page 40: Docker Introduction

VersionEye Enterprise

VersionEye Enterprise VM

veye:rails_app:1.0.0

veye:rails_api:1.0.0

veye:rails_tasks:1.0.0

reiz:mongodb:1.0.0

reiz:elasticsearch:1.0.0

reiz:memcached:1.0.0

The same Docker containers which run in the Cloud run on VersionEye Enterprise.

For Orchestration Ansible is used.

Page 41: Docker Introduction

Demo

Page 42: Docker Introduction

? ? ? @RobertReiz