dockerize the world - presentation from hradec kralove

58
Dockerize the world! Martin Damovský

Upload: damovsky

Post on 13-Jan-2017

5.513 views

Category:

Software


0 download

TRANSCRIPT

Page 1: Dockerize the World - presentation from Hradec Kralove

Dockerize the world!

Martin Damovský

Page 2: Dockerize the World - presentation from Hradec Kralove

My plan for today

• Introduction to Docker

• Some demos

• Docker in Cloud

• IoT and Docker

• News from DockerCon 2015 in SF and Barcelona

Page 3: Dockerize the World - presentation from Hradec Kralove

Who am I?

• Software engineer (java, DBs, continuous integrations, docker, etc.)

• Grew up in small city near Ostrava

• Tieto Czech s.r.o. Ostrava, Gemalto in Prague

• Now in Vendavo CZ in Prague

• Twitter @damovsky

Page 4: Dockerize the World - presentation from Hradec Kralove

Who knows Docker?

Page 5: Dockerize the World - presentation from Hradec Kralove

Who uses Docker in production?

Page 6: Dockerize the World - presentation from Hradec Kralove

What is ?

• Docker is virtualization technology

• With docker you can:

• virtualize only the app and not the whole OS

• Isolate each app

• Restrict CPU / memory / for each app

• Easily distribute your app

• Automate your development / test / production environment

Page 7: Dockerize the World - presentation from Hradec Kralove

What is ?

• Docker is a whole platform for using containers

• Includes tools for:

• container sharing

• orchestrations, clustering, etc.

Page 8: Dockerize the World - presentation from Hradec Kralove

What is ?

• Docker is for Linux only

• But…Microsoft works on Docker for Windows

• Apple (MacOS) = no native support planned

Page 9: Dockerize the World - presentation from Hradec Kralove

Docker project• Docker inc. is a sponsor of “Docker” open source project

• https://github.com/docker/docker

• Written in Go

• Main contributors: Docker team, RedHat, IBM, Google, Cisco…

• Initial release: 13 March 2013

• Operation system: Linux

• www.docker.com

Page 10: Dockerize the World - presentation from Hradec Kralove
Page 11: Dockerize the World - presentation from Hradec Kralove

Docker vs VM

Page 12: Dockerize the World - presentation from Hradec Kralove

How does it works?

• Use Linux kernel support for isolation (CPU, memory, I/O, network….)

• Cgroups – linux kernel feature to limit resource usages

• Namespaces – linux kernel feature to isolate services from each other

• Earlier LXC – https://linuxcontainers.org

• Now – runC (Libcontainer) https://github.com/opencontainers/runc

Page 13: Dockerize the World - presentation from Hradec Kralove

Docker mottoBuild – build container with your app

Ship - use docker registry to distribute your app

Run - wherever docker runs, your app will run as well

Page 14: Dockerize the World - presentation from Hradec Kralove

DockerFile = cookbook for docker image• Recipe for building the image• Easy to transfer copy&paste• Easy for versioning in Git, etc..

FROM debian:wheezy

RUN apt-get updateRUN apt-get install -y python2.7

CMD python2.7 -m SimpleHTTPServer 8000

Page 15: Dockerize the World - presentation from Hradec Kralove

Docker “flow”1. create docker file2. build dockerfile

$ docker build -t myTagName .3. run container

$ docker run -d myTagName

Page 16: Dockerize the World - presentation from Hradec Kralove

Dockerfile• # Demo 01• https://asciinema.org/a/7m72btfpczbshfkxh26smwgqv

Page 17: Dockerize the World - presentation from Hradec Kralove

Dockerfile commands• FROM

• RUN

• CMD

• ADD

• USER

• ENV

• etc….see at http://docs.docker.com/reference/builder/

Page 18: Dockerize the World - presentation from Hradec Kralove

It’s all about the money!LAYERS!

Page 19: Dockerize the World - presentation from Hradec Kralove

Dockerfile vs layersFROM debian:wheezy

RUN apt-get updateRUN apt-get install -y python2.7

CMD python2.7 -m SimpleHTTPServer 8000

└─61f… Virtual Size: 85.1 MB Tags: debian:wheezy └─5b8.. Virtual Size: 93.4 MB

└─604.. Virtual Size: 123.5 MB└─43e.. Virtual Size: 123.5 MB Tags: python:latest

Page 20: Dockerize the World - presentation from Hradec Kralove

Dockerfile, build, run• # Demo 02

• Python http server + Connect to container

Page 21: Dockerize the World - presentation from Hradec Kralove

Docker Image

Base Image (debian/ubuntu/…)

Page 22: Dockerize the World - presentation from Hradec Kralove

Docker Image

Base Image (debian/ubuntu/busybox…)

Image – Added Apache

Page 23: Dockerize the World - presentation from Hradec Kralove

Docker Image Container

Base Image (debian/ubuntu/busybox…)

Image – Added Apache

Writable Layer

Page 24: Dockerize the World - presentation from Hradec Kralove

Docker Container and its file system layers

Base Image (debian/ubuntu/busybox…)

Image – Added Apache

Writable Layer

Image – Added MySQL

Writable Layer

Container #1 Container #2

Page 25: Dockerize the World - presentation from Hradec Kralove

Docker registry• https://registry.hub.docker.com/

• Official repo (trusted builds)

• WordPress, MySQL, NgInx, Node, CentOS, Ubuntu, Postgress, mongo, rails, ruby, java,

python, golang, jenkins, php, tomcat, maven, httpd, …

• Public repo with thousands of images

• Integration with GitHub

• You push the Dockerfile to github

• Docker Registry builds the docker image for you

Page 26: Dockerize the World - presentation from Hradec Kralove

Docker requirements• Technical:• Linux kernel 3.10 +

• Knowledge:• Linux, bash scripting, etc

Page 27: Dockerize the World - presentation from Hradec Kralove

Docker on Windows / Mac OS

Page 28: Dockerize the World - presentation from Hradec Kralove

Linux

Docker daemon

Container

Container

Container

Docker client

Mac OS / Windows

VM with Linux

Docker daemon

Container

Container

Container

Docker client

Page 29: Dockerize the World - presentation from Hradec Kralove

Docker API•http://docs.docker.com/engine/reference/api/docker_remote_api_v1.21/•REST API for everything•Container management• Image management•Docker configuration, etc…

Page 30: Dockerize the World - presentation from Hradec Kralove

Docker itself is….like a java

Without tools and frameworks it’s useless

Page 31: Dockerize the World - presentation from Hradec Kralove

Docker Toolbox• Docker engine

• Kinematic – GUI, runs on MacOS + Windows• Docker Machine – automates Docker environment preparation• Docker Compose – define multi-container application in one file• Demo 03

• Docker Swarm – clustering the containers

Page 32: Dockerize the World - presentation from Hradec Kralove

Where can Docker be helpful?

Page 33: Dockerize the World - presentation from Hradec Kralove

…when new dev starts configuring project

Page 34: Dockerize the World - presentation from Hradec Kralove

…it works on my machine!

Page 35: Dockerize the World - presentation from Hradec Kralove

J2EE Application in Docker - demo

Page 36: Dockerize the World - presentation from Hradec Kralove

J2EE Application in Docker - demo• https://github.com/mgreau/docker4dev-tennistour-app• https://asciinema.org/a/2d6erl2tlu1j0b3rfvxwabnkv• #Demo 04

Page 37: Dockerize the World - presentation from Hradec Kralove
Page 38: Dockerize the World - presentation from Hradec Kralove

Docker and IoT (Raspberry Pi)• ARM vs x86/64 architecture• Docker to plan official support ARM• HypriotOS – linux distro for Raspberry• Hypriot OS based images: • https://hub.docker.com/u/hypriot/

Page 39: Dockerize the World - presentation from Hradec Kralove

RPI 2 + Docker = 2499 containers• LIVE DEMO – hypriot OS httpd• https://vimeo.com/131966874• http://www.slideshare.net/Docker/docker-online-meetup-27-raspberr

y-pi-dockercon-challenge

Page 40: Dockerize the World - presentation from Hradec Kralove

Docker in Cloud• Digital Ocean• UI Tutum.co – worth to try!

• Amazon• Microsoft Azure• Google Cloud

Page 41: Dockerize the World - presentation from Hradec Kralove

$ Price $• Digital Ocean: $5 / 512 MB, 1 core, 20 GB SSD, 1TB Transfer• Amazon: it depends on many factors• Microsoft Azure• Google Cloud: free up to 5 nodes, 6+ nodes $0.15 HR/Cluster • Alternative: VSPFree.cz 4GB RAM, 8 cores, 900 Kč /3 Months

Page 42: Dockerize the World - presentation from Hradec Kralove

Docker and Microsoft ???

Page 43: Dockerize the World - presentation from Hradec Kralove

Docker and Microsoft ?

Page 44: Dockerize the World - presentation from Hradec Kralove

Docker and Microsoft ?• Microsoft contributes to docker• see pull request https://github.com/docker/docker/pull/9113

• Microsoft Azure supports docker• Native Docker on Windows Server is coming…

Page 45: Dockerize the World - presentation from Hradec Kralove

Docker and PHP ?• Piece of cake ;-)• #Demo 05

Page 46: Dockerize the World - presentation from Hradec Kralove

Docker orchestration• Docker Swarm• Kubernetes• Apache Mesos

Page 47: Dockerize the World - presentation from Hradec Kralove

Run GUI in Docker?• https://blog.jessfraz.com/post/docker-containers-on-the-desktop/• #Demo 06

Page 48: Dockerize the World - presentation from Hradec Kralove
Page 49: Dockerize the World - presentation from Hradec Kralove

Dockercraft• A simple Minecraft Docker client, to visualize and manage Docker

containers.

Page 51: Dockerize the World - presentation from Hradec Kralove

What’s in Docker roadmap?• Official ARM support• Docker on Windows Server• Docker on IBM systems, Solaris

Page 52: Dockerize the World - presentation from Hradec Kralove

Troubles you may face….

….with Docker

Page 53: Dockerize the World - presentation from Hradec Kralove

Docker Registry - Image Repository• Public – no way for 99,9% apps

• Private• Limitation – money & your internet connection speed

• Local repo - can require some management• Authentication (users/passwords/roles, etc…)• cleaning olds images• disk space• backup (!!!!)

Page 54: Dockerize the World - presentation from Hradec Kralove

Docker Public Registry and license terms

Page 55: Dockerize the World - presentation from Hradec Kralove

Unrealistic tutorials and demos• Demos = “wow effect”• Typical problem for production use – database in container • Database container can really be big! (>10 GB or more)• Data should be outside of container and backuped• Virtualization decreases the performance

Page 56: Dockerize the World - presentation from Hradec Kralove

Docker containers and images• Image is too big -> Squash layers• Container has been stopped, but it blocks the port...• Stopped != removed• docker ps -a -q | xargs -n 1 -I {} docker rm {}

Page 57: Dockerize the World - presentation from Hradec Kralove

Run Docker on dedicated machine only• You should use the latest Linux Kernel• Some bug fixes may require you to update Linux Kernel• Who can update Linux kernel in production?

• Which file system to use? BTRFS / AUFS / ?• Which OS ?• Core OS• RancherOS• Well known like a CentOS, Red Hat, Ubuntu ?

Page 58: Dockerize the World - presentation from Hradec Kralove

Links:• My demos• https://github.com/damovsky/jug-ostrava-docker

• Yowie – Open source project by @VitekTajzich• https://github.com/vendavo/yowie