41
DOCKER FOR POLYGLOTS Nathan LeClaire, Open Source Engineer at Docker Inc.

"Docker For Polyglots" - Nathan LeClaire - YAPC::Asia 2015

Embed Size (px)

Citation preview

Page 1: "Docker For Polyglots" - Nathan LeClaire - YAPC::Asia 2015

DOCKER FOR POLYGLOTSNathan LeClaire, Open Source Engineer at Docker Inc.

Page 2: "Docker For Polyglots" - Nathan LeClaire - YAPC::Asia 2015

WELCOME

• I appreciate your participation ! To speak at this conference is an honor.

• Today we are going to talk about "Docker For Polyglots".

• A "polyglot" is someone who speaks multiple languages.

Page 3: "Docker For Polyglots" - Nathan LeClaire - YAPC::Asia 2015

THANK YOU FOR CONFERENCE

Page 4: "Docker For Polyglots" - Nathan LeClaire - YAPC::Asia 2015

WHO AM I?Nathan LeClaire (@upthecyberpunks)

Open Source Engineer, Docker Machine

Page 5: "Docker For Polyglots" - Nathan LeClaire - YAPC::Asia 2015

I ❤ JAPAN

Page 6: "Docker For Polyglots" - Nathan LeClaire - YAPC::Asia 2015

TOOLS OF MASSIVE INNOVATION

Page 7: "Docker For Polyglots" - Nathan LeClaire - YAPC::Asia 2015

TOOLS OF MASSIVE INNOVATION

Page 8: "Docker For Polyglots" - Nathan LeClaire - YAPC::Asia 2015

LET'S LOOK AT SOME FACTS

Page 9: "Docker For Polyglots" - Nathan LeClaire - YAPC::Asia 2015

FACT: VARIETY

• Developers want to use a variety of programming languages

• "The right tool for the right job"

• This complicates the process of setting up development environments and running operations

Page 10: "Docker For Polyglots" - Nathan LeClaire - YAPC::Asia 2015

FACT: TECHNOLOGY CHANGES RAPIDLY• Front end web development alone has a huge

explosion of options including SASS, Grunt, Yeoman, etc.

• Not every developer on your team is going to be an expert in tooling for every language but they still might want to contribute

• More friction == less productivity

Page 11: "Docker For Polyglots" - Nathan LeClaire - YAPC::Asia 2015

FACT: TOOLING IS DIFFICULT

• For instance, Maven might be intimidating to a Go developer.

• Python programmers might want to use Ruby sometimes but don't know how to use rbenv or rvm

• Contributing to open source is very difficult for this reason.

Page 12: "Docker For Polyglots" - Nathan LeClaire - YAPC::Asia 2015

FACT: "BUS FACTOR" RISK IS HIGH

• If "the person who sets up the environments" on your team was hit by a bus tomorrow, would it be easy or hard to keep going?

• Can any person on your team destroy their development environment and re-build it from scratch automatically?

Page 13: "Docker For Polyglots" - Nathan LeClaire - YAPC::Asia 2015

FACT: DEPENDENCY HELLDoes this type of thing look familiar?

Page 14: "Docker For Polyglots" - Nathan LeClaire - YAPC::Asia 2015

DOCKER CAN HELP

• Docker provides a way of distributing applications

• It also provides orchestration tools for developing them

• End game is to reduce friction to the point where transitioning between projects is seamless

Page 15: "Docker For Polyglots" - Nathan LeClaire - YAPC::Asia 2015
Page 16: "Docker For Polyglots" - Nathan LeClaire - YAPC::Asia 2015
Page 17: "Docker For Polyglots" - Nathan LeClaire - YAPC::Asia 2015
Page 18: "Docker For Polyglots" - Nathan LeClaire - YAPC::Asia 2015

MY DREAM: SIMPLICITY

Page 19: "Docker For Polyglots" - Nathan LeClaire - YAPC::Asia 2015

MY DREAM: UNIFORMITY

Page 20: "Docker For Polyglots" - Nathan LeClaire - YAPC::Asia 2015

MY DREAM: PHOENIX DEVELOPMENT

Page 21: "Docker For Polyglots" - Nathan LeClaire - YAPC::Asia 2015

WHAT IS A POLYGLOT?"PROGRAMMING LANGUAGE"

Page 22: "Docker For Polyglots" - Nathan LeClaire - YAPC::Asia 2015

WHAT IS A POLYGLOT?"TOOLING LANGUAGE"

Page 23: "Docker For Polyglots" - Nathan LeClaire - YAPC::Asia 2015

WHAT IS A POLYGLOT?"DEVELOPER LANGUAGE"

"We need to add some migrations to run for the database, a few

controllers, and also some jobs to run in the background queue."

Page 24: "Docker For Polyglots" - Nathan LeClaire - YAPC::Asia 2015

WHAT IS A POLYGLOT?"OPERATOR LANGUAGE"

"Let's set up some automation around our load balancers, store these files in an S3 bucket and consider moving to a cross-cloud solution with overlay networking."

Page 25: "Docker For Polyglots" - Nathan LeClaire - YAPC::Asia 2015

DOCKER LETS YOU DEFINE AN ENVIRONMENT SIMPLY

Page 26: "Docker For Polyglots" - Nathan LeClaire - YAPC::Asia 2015

EXAMPLE

Page 27: "Docker For Polyglots" - Nathan LeClaire - YAPC::Asia 2015

I DON'T KNOW ANYTHING ABOUT LUA...

...AND ONLY A LITTLE ABOUT NGINX.

Page 28: "Docker For Polyglots" - Nathan LeClaire - YAPC::Asia 2015

SETTING UP OPENRESTY MANUALLY

$ sudo apt-get install -y make build-essential libreadline-dev libncurses5-dev libpcre3-dev libssl-dev perl make build-essential

$ # Go to browser, click around on "Download Page"

$ wget https://openresty.org/download/ngx_openresty-1.9.3.1.tar.gz

$ tar xvf ngx_openresty-1.9.3.1.tar.gz

$ cd ngx_openresty-1.9.3.1

$ ./configure; make; make install

Page 29: "Docker For Polyglots" - Nathan LeClaire - YAPC::Asia 2015

FORTUNATELY THAT PROJECT HAS GOOD DOCUMENTATION,

BUT WHAT IF IT DIDN'T?

Page 30: "Docker For Polyglots" - Nathan LeClaire - YAPC::Asia 2015

WHAT IF YOU WANT TO INSTALL AUTOMATICALLY ON ANOTHER COMPUTER?

OR EASILY SHARE YOUR APPLICATION WITH A FRIEND OR COLLEAGUE?

Page 31: "Docker For Polyglots" - Nathan LeClaire - YAPC::Asia 2015

REPLACE MANUAL METHOD WITH A TINY BASH SCRIPT?

Page 32: "Docker For Polyglots" - Nathan LeClaire - YAPC::Asia 2015

"YEAH, I KNOW YOU DEVELOP ON DEBIAN, BUT THIS NEEDS TO RUN ON

RHEL."

Page 33: "Docker For Polyglots" - Nathan LeClaire - YAPC::Asia 2015

DEVELOPER

Installing software is boring! I just want to script nginx with Lua!

Page 34: "Docker For Polyglots" - Nathan LeClaire - YAPC::Asia 2015

SOLUTION

Page 35: "Docker For Polyglots" - Nathan LeClaire - YAPC::Asia 2015

WE CAN MAKE DOCKERFILE.IT WILL RUN ON ANY OS WITH

COMPATIBLE KERNEL.from debian:jessie

run apt-get update run apt-get install -y \ libreadline-dev \ libncurses5-dev \ libpcre3-dev \ libssl-dev \ perl \ wget \ make \ build-essential run mkdir -p /openresty workdir /openresty env OPENRESTY_VERSION 1.7.10.2 run wget http://openresty.org/download/ngx_openresty-${OPENRESTY_VERSION}.tar.gz run tar xzvf ngx_openresty-${OPENRESTY_VERSION}.tar.gz run cd ngx_openresty-${OPENRESTY_VERSION}/ && \ ./configure && \ make && \ make install env PATH /usr/local/openresty/nginx/sbin:$PATH add https://get.docker.com/builds/Linux/x86_64/docker-latest /docker run chmod +x /docker add . /app workdir /app entrypoint ["./entrypoint.sh"]

Page 36: "Docker For Polyglots" - Nathan LeClaire - YAPC::Asia 2015

BUILD, SHIP, & RUN

$ docker build -t nathanleclaire/openresty . $ docker push nathanleclaire/openresty $ # Now we can pull from anywhere! $ # On another computer... $ docker run -d -P nathanleclaire/openresty

Page 37: "Docker For Polyglots" - Nathan LeClaire - YAPC::Asia 2015

YOU CAN USE AUTOMATED BUILDS ON DOCKER HUB TO LEARN FROM OTHER

PEOPLE

Page 38: "Docker For Polyglots" - Nathan LeClaire - YAPC::Asia 2015

LOTS OF CONTRIBUTION TO DOCKER BECAUSE OF DOCKER

Page 39: "Docker For Polyglots" - Nathan LeClaire - YAPC::Asia 2015

DOCKER MACHINE

Page 40: "Docker For Polyglots" - Nathan LeClaire - YAPC::Asia 2015

DOCKER COMPOSE

Page 41: "Docker For Polyglots" - Nathan LeClaire - YAPC::Asia 2015

DOCKER SWARM