gdg using docker to streamline development

37
© Mesan AS Streamline Your Development Process with Docker Trond Marius Øvstetun [email protected] GDG DevFest 2014

Upload: trond-marius-ovstetun

Post on 13-Jul-2015

109 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Gdg using docker to streamline development

© Mesan AS

Streamline Your Development

Process with Docker

Trond Marius Ø[email protected]

GDG DevFest 2014

Page 2: Gdg using docker to streamline development

© Mesan AS

Streamline with Docker

Page 3: Gdg using docker to streamline development

© Mesan AS

About me

• Trond Marius Øvstetun

• CTO in Mesan

• Developer, Architect, Tech-lead+++

• 10+ years of experience building applications

Page 4: Gdg using docker to streamline development

© Mesan AS

How we build systems

Modern challenges

Page 5: Gdg using docker to streamline development

© Mesan AS

Page 6: Gdg using docker to streamline development

© Mesan AS

Challenges

• One big lump of software

• Scales as one

• Deploys as one

• Updates as one

• Develops as one

Page 7: Gdg using docker to streamline development

© Mesan AS

Breaking the Monolith

Page 8: Gdg using docker to streamline development

© Mesan AS

Page 9: Gdg using docker to streamline development

© Mesan AS

Page 10: Gdg using docker to streamline development

© Mesan AS

A new set of challenges

• Interdependencies

• Implicit ones - keys shared across systems

Page 11: Gdg using docker to streamline development

© Mesan AS

From a developers perspective

• Dependencies change

• add more systems

• systems change

• different kinds of deps

• search/messaging/storage/caching…

• How do we deal with this?

• try to run deps locally?

• export/import data

• the “shared development environment”

• moar, moar environments

Page 12: Gdg using docker to streamline development

© Mesan AS

Page 13: Gdg using docker to streamline development

© Mesan AS

What is Docker?

“Docker is an open platform for developers and sysadmins to build, ship, and run distributed applications.”

• Deploying and shipping software consistently is too hard

• Dependencies, libraries, configuration

• Consistency across environments (local, test, QA, production)

• A new abstraction – introduce the Container

Page 14: Gdg using docker to streamline development

© Mesan AS

What is a container?

Page 15: Gdg using docker to streamline development

© Mesan AS

What is a container?

• Lightweight linux environment

• Hermetically sealed, deployable

• Isolation

• Portability

• Raising the level of abstraction

• VMs = Idealized hardware

• Container = Idealized OS (+hardware)

Page 16: Gdg using docker to streamline development

© Mesan AS

Demos

Page 17: Gdg using docker to streamline development

© Mesan AS

Basic examples

• Docker Hello World!

$ docker run hello-world

• Interactive running in a container (or two!)

$ docker run -it ubuntu bash

• Running basic nginx in a container

$ docker run -d nginx

Page 18: Gdg using docker to streamline development

© Mesan AS

Building a container manually

• Run commands in interactive mode

• Commit changes

• Takes time –boring, manual & error prone

• What about reproducability?

$ docker run -i -t ubuntu bash

root@171950c2cf9d:/# touch my.conf

root@171950c2cf9d:/# vi my.conf

root@171950c2cf9d:/# apt-get install my-package

Reading package lists... Done

Building dependency tree

Reading state information... Done

$ docker commit 171950c2cf9d ovstetun/my

Page 19: Gdg using docker to streamline development

© Mesan AS

Dockerfile

my

Dockerfile + env

$ docker build .

$ docker build -t mynginx .

Page 20: Gdg using docker to streamline development

© Mesan AS

Exposing ports as Services

• Expose ports from a containerin the Dockerfile

EXPOSE 3000

• Open ports on the server

$ docker run -p 4000:3000 mynginx

Page 21: Gdg using docker to streamline development

© Mesan AS

Linking containers

• Declare dependency and link

docker run --link 1bc1:mysql nginx

• Available as environment variables

MYSQL_PORT_3306_TCP_ADDR=xxx

MYSQL_PORT_3306_TCP_PORT=xxx

Page 22: Gdg using docker to streamline development

© Mesan AS

Sharing containers

• Docker Hub

• Official reusable images

• Your own!

$ docker push ovstetun/mynginx

Page 23: Gdg using docker to streamline development

© Mesan AS

Developing using Docker

Exemplifying a workflow and setup

Page 24: Gdg using docker to streamline development

© Mesan AS

Example system

Page 25: Gdg using docker to streamline development

© Mesan AS

Setting up your system for Docker

• Depend on Services, not Resources or computers

• Run the same, identical container everywhere

• Docker links to Services

• Automate changes

• Database refactorings

• Search index updates

• …

Page 26: Gdg using docker to streamline development

© Mesan AS

Setting up your system for Docker

• One process per container

• Reuse (your own) base images

• Repeatable builds – use Dockerfiles

• Automate everything

Page 27: Gdg using docker to streamline development

© Mesan AS

Workflow

Page 28: Gdg using docker to streamline development

© Mesan AS

Working with dependencies

• Do some work in Ingredients module

• Run dependencies in Docker

• search + database

$ docker run -p 3306:3306 --name some-mysql \\

-e MYSQL_ROOT_PASSWORD=pwd -d o/ftdb:2

$ docker run -p 9300:9300 --name elastic \\

-d o/ftelastic:2

Page 29: Gdg using docker to streamline development

© Mesan AS

• Automatic linkingand management

• Simple configuration

Page 30: Gdg using docker to streamline development

© Mesan AS

Demo

Page 31: Gdg using docker to streamline development

© Mesan AS

Deploying to the Cloud

Page 32: Gdg using docker to streamline development

© Mesan AS

Page 33: Gdg using docker to streamline development

© Mesan AS

Kubernetes

• Master & Minions

• Pods

• collection of containers, run as a unit

• ReplicationControllers

• controllable

• Services

• proxy layer and load balancing – “dynamic Docker links”

Page 34: Gdg using docker to streamline development

© Mesan AS

Kubernetes

Page 35: Gdg using docker to streamline development

© Mesan AS

The future?

• The future lies in containers

• continue to see more examples of use cases

• Docker is the leader today

• The momentum is gigantic

• google, Microsoft, RedHat, Rackspace +++

Page 36: Gdg using docker to streamline development

© Mesan AS

Q & A

Page 37: Gdg using docker to streamline development

© Mesan AS

Thank you

[email protected]/ovstetun/jz14

@ovstetun