introduction to docker and linux containers @ cloud computing rhein main

40
Docker Intro Puja Abbassi @puja108 http://giantswarm.io

Upload: puja-abbassi

Post on 13-Aug-2015

206 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introduction to Docker and Linux Containers @ Cloud Computing Rhein Main

Docker IntroPuja Abbassi@puja108http://giantswarm.io

Page 2: Introduction to Docker and Linux Containers @ Cloud Computing Rhein Main

Simple microservice infrastructure, built for developers.

Currently in free AlphaLooking for feedbackhttp://giantswarm.io/

We’re hiring

Page 3: Introduction to Docker and Linux Containers @ Cloud Computing Rhein Main

Agenda

1) Docker Intro● Why are we so excited?● What is Docker?● Getting started

2) Docker Microservices

Page 4: Introduction to Docker and Linux Containers @ Cloud Computing Rhein Main

Docker is an open-source project to easily create lightweight, portable, self-sufficient containers from any application.”

“Linux

Page 5: Introduction to Docker and Linux Containers @ Cloud Computing Rhein Main

Why are we so excited?

Page 6: Introduction to Docker and Linux Containers @ Cloud Computing Rhein Main

Installation

My Mac Timo’s Linux

Test Staging Cloud VM Bare Metal

Rails Web Frontend ? ? ? ? ? ?

Node.jsAPI ? ? ? ? ? ?

Background jobs ? ? ? ? ? ?

MySQL ? ? ? ? ? ?

Distributed DB ? ? ? ? ? ?

Message Queue ? ? ? ? ? ?

Page 7: Introduction to Docker and Linux Containers @ Cloud Computing Rhein Main

Reusable Containers

My Mac Timo’s Linux

Test Staging Cloud VM Bare Metal

Rails Web Frontend

Node.jsAPI

Background jobs

MySQL

Distributed DB

Message Queue

Page 8: Introduction to Docker and Linux Containers @ Cloud Computing Rhein Main

Speed

Ships within ...

Manual deployment

takes ...

Automated deployment

takes ...Boots in ...

Bare metal Days Hours Minutes Minutes

Virtual machine Minutes Minutes Seconds < Minute

Container Seconds Minutes Seconds Seconds

Page 9: Introduction to Docker and Linux Containers @ Cloud Computing Rhein Main

Dev ⇔ DevOps - Separation of Concerns

Dev: Inside the container● my code● my libraries● my package

manager● my app● my data

Ops: Outside the container● Logging● Remote Access● Network

Configuration● Monitoring

Page 10: Introduction to Docker and Linux Containers @ Cloud Computing Rhein Main

Who’s Using Containers?

Page 11: Introduction to Docker and Linux Containers @ Cloud Computing Rhein Main

What is Docker?

Page 12: Introduction to Docker and Linux Containers @ Cloud Computing Rhein Main

Based on existing technologies

● Namespaces> Varying views on the system> to provide isolated environments> PID, NET, IPC, MNT, UTS, User

● CGroups> control resources for a group of processes> like CPU time, Memory, Network bandwidth, etc.

● Layered FS● (LXC)

Page 13: Introduction to Docker and Linux Containers @ Cloud Computing Rhein Main

Layered FS

Base Image

Image

bootfs

Image

Writable Container Application Code

NodeJS

Nginx

Ubuntu

Cgroups, Namespaces, Device Mapper, Kernel

Page 14: Introduction to Docker and Linux Containers @ Cloud Computing Rhein Main

But {insert some great UNIX here} has had this for years.”“

Page 15: Introduction to Docker and Linux Containers @ Cloud Computing Rhein Main

Docker History

● Jan 2013: Initial commit● September 2013: Redhat announces

collaboration● June 2014: Google announces engagement● August 2014: VMWare announces Docker support● February 2015: Microsoft announces Docker

support● April 2015: Docker raises $95 Million● June 2015: Open Container Project announced

Page 16: Introduction to Docker and Linux Containers @ Cloud Computing Rhein Main
Page 17: Introduction to Docker and Linux Containers @ Cloud Computing Rhein Main
Page 18: Introduction to Docker and Linux Containers @ Cloud Computing Rhein Main

Docker is awesomeand here to stay.

Page 19: Introduction to Docker and Linux Containers @ Cloud Computing Rhein Main

Getting started

Page 20: Introduction to Docker and Linux Containers @ Cloud Computing Rhein Main

Installation

● Mac, Windows: Boot2Docker

● Ubuntu:$ sudo apt-get install docker.io

Page 21: Introduction to Docker and Linux Containers @ Cloud Computing Rhein Main

Run Containers

# run a command

$ docker run busybox echo hello

# run an interactive shell

$ docker run -i -t busybox /bin/sh

# run a Redis cache

$ docker run -d redis

Page 22: Introduction to Docker and Linux Containers @ Cloud Computing Rhein Main

A Node Script

// server.jsvar http = require('http');

http.createServer(function (req, res) {

res.writeHead(200, {'Content-Type': 'text/plain'});

res.end('Hello World\n');

}).listen(8080);

console.log('Server running');

Page 23: Introduction to Docker and Linux Containers @ Cloud Computing Rhein Main

Simple Dockerfile

FROM ubuntu:latest

RUN apt-get update

RUN apt-get install -y nodejs

ADD server.js .

EXPOSE 8080

CMD ["/usr/bin/nodejs", "/server.js"]

Page 24: Introduction to Docker and Linux Containers @ Cloud Computing Rhein Main

Build, Push, and Run

# build the image

$ docker build -t puja108/node .

# push it to the registry

$ docker push puja108/node

# run it (on any host)

$ docker run -d puja108/node

Page 25: Introduction to Docker and Linux Containers @ Cloud Computing Rhein Main

dockerbook.com

Page 26: Introduction to Docker and Linux Containers @ Cloud Computing Rhein Main

Docker in Development

Page 27: Introduction to Docker and Linux Containers @ Cloud Computing Rhein Main

● Vagrant● rbenv● nodeenv● virtualenv● Laptop full of build tools and servers

Your current setup?

Page 28: Introduction to Docker and Linux Containers @ Cloud Computing Rhein Main

● Contains Build Tools○ Can also be a separate container

● One (or more) container(s) for each stack○ Use Docker Compose

● Runs the same regardless on which host or in which environment

● Lightweight○ Developer can actually have several environments

open directly on her laptop

Dev Containers

Page 29: Introduction to Docker and Linux Containers @ Cloud Computing Rhein Main

Docker Build Chain

Page 30: Introduction to Docker and Linux Containers @ Cloud Computing Rhein Main

Jenkins - Docker Hub Integration

Jenkins - Docker Hub Integration

Page 31: Introduction to Docker and Linux Containers @ Cloud Computing Rhein Main

Docker Enables new Architecture Patterns

Page 32: Introduction to Docker and Linux Containers @ Cloud Computing Rhein Main

Patterns for the Cloud

Microservices

Responsive Manifesto

Page 33: Introduction to Docker and Linux Containers @ Cloud Computing Rhein Main

● Microservice Architectures> Simple focussed services> Highly decoupled> Communicate over lightweight mechanisms

> HTTP APIs & Message Queues> Polyglot (Language, Framework, Data Store)> Built to fail

● Immutable Infrastructures> Disposable components> Make your state explicit> Configure at run-time

The Next Steps in Cloud Architecture

Page 34: Introduction to Docker and Linux Containers @ Cloud Computing Rhein Main

Containers vs. VMs

Container● Lightweight layers

above a shared kernel

● Single service or process

● New but promising technology

● Enable #GIFEE

VM● Complete (heavy)

Virtual System

● Application(s) with several components

● Tried and trusted Technology

Page 35: Introduction to Docker and Linux Containers @ Cloud Computing Rhein Main

Should I start with Docker?

Page 36: Introduction to Docker and Linux Containers @ Cloud Computing Rhein Main

Yes!

Page 37: Introduction to Docker and Linux Containers @ Cloud Computing Rhein Main

Containers are only 1% of your problem.”“

Kelsey Hightower,

CoreOS

Page 38: Introduction to Docker and Linux Containers @ Cloud Computing Rhein Main

Thanks for listening!Reach out:Puja Abbassi@puja108@giantswarm

Page 39: Introduction to Docker and Linux Containers @ Cloud Computing Rhein Main

Namespaces

The pid namespace: Used for process isolation (PID: Process ID).The net namespace: Used for managing network interfaces (NET: Networking).The ipc namespace: Used for managing access to IPC resources (IPC: InterProcess Communication).The mnt namespace: Used for managing mount-points (MNT: Mount).The uts namespace: Used for isolating kernel and version identifiers. (UTS: Unix Timesharing System).

Page 40: Introduction to Docker and Linux Containers @ Cloud Computing Rhein Main

CGroups

Control group of processes.Share available hardware resources.Set up limits and constraints. E.g. limiting the memory available to a specific container.