29
DOCKER IN DEVELOPMENT

Docker in development

Embed Size (px)

Citation preview

Page 1: Docker in development

D O C K E R I N D E VE LO P M E N T

Page 2: Docker in development

O B L I G AT O RY D O C K E R I N T R OD O CK E R I S YO U R F R I E N D

Page 3: Docker in development

W H O U S E S I T ?

Page 4: Docker in development

W H Y I S I T I M PO RTAN T ?

Standardized

Composable

Reusable

Sandboxed

Page 5: Docker in development

S A N D BOX E D ?

The processes within the container are unaware of the parent Linux system.

Multiple instances of the same exact image can run side-by-side without conflicting or being aware of each other.

Page 6: Docker in development

C O M P O S AB L E ?

Link multiple containers explicitly or expose ports to the parent Linux machine which may then be connected to by outside users and services.

Single responsibility for each image, using multiple images and instances in concert to create applications.

Page 7: Docker in development

H O W D O E S I T D O I T ?

• Reduces duplication

• Containers not Hypervisors

• cgroups, UnionFS, libcontainer

Image credit: http://www.lifeintech.com/blog/2014/7/19/containerisation-is-the-new-virtualisation

Page 8: Docker in development

A B I T O F H I S T O RYLO C A L D E V E LO P M E N T

Page 9: Docker in development

V I RT U A L BOX

• Originally by Sun, now Oracle – free and open source

• Like Parallels and VMWare, emulates hardware, requires manual setup

• Fully encapsulate your application in it’s own environment

• Scriptable using CLI tools

Page 10: Docker in development

VAG RAN T

• Vagrant allowed programmatic creation of VMs without manual intervention

• Integration with Puppet, Chef and shell scripts eased setup

• Re-use existing deployment scripts to install dependencies

Page 11: Docker in development

BO O T 2 D O C K E R

• Boot2Docker brings Docker to the Mac

• Uses VirtualBox in the background, much like Vagrant

• Very lightweight base Linux image (≈20MB!)

• Manages shell variables to specify the VM as the remote Docker server

• Call `docker` commands locally, transparently sent to VM

Page 12: Docker in development

F I G

• Originally written by Orchard Labs, a Docker hosting service

• Allowed definition of multiple docker images through a single YAML file

• Handled most of Dockers CLI features – images, volumes, ports, linking

• Acquired by Docker, Inc. in July 2014

Page 13: Docker in development

D O C K E R- C O M P O S E

• Fig renamed to Docker Compose, transition completed late February 2015

• Extended to work in conjunction with new orchestration tools Docker Machine and Docker Swarm

• Already large user-base gained more traction, increased usage meant more bugs found and fixed.

• Future uses will include managing production resources as well

Page 14: Docker in development

W H AT AR E W E B U I L D I N G ?T H E P R O J E CT A N D PA RT S

Page 15: Docker in development

S Q L DATAB AS E – P O S T G R E S Q L• Besides being the db du jour,

PostgreSQL offers a more modern subset of the SQL specification

• Additional column types such as JSON, BSON & HStore

• Much better support for new functionality (PostGIS) through Pg/SQL and other languages (Javascript, Python, Ruby, &c.)

Page 16: Docker in development

K-V DATAB AS E – R E D I S

• Fast, lightweight, easy to install, no dependencies

• Atomic reads and writes

• Can be clustered and sharded for horizontal scalability

• List data type ideal for queue system

Page 17: Docker in development

AS Y N C W O R K E R –   S I D E K I Q

• Uses Redis’ atomic list reads and writes to manage a reliable queue

• Threaded workers allow for fast spin up and execution, many more can run simultaneously than alternatives

• Integrates nicely with Rails, including Rails 4.2 native ActiveJob workers

Page 18: Docker in development

P R I M ARY AP P –   RA I L S• This is my framework. There are many

like it but this one is mine.

• My framework is my best friend. It is my life. I must master it as I must master my life.

• Seriously, though, I have used Rails since 2.1 and am comfortable using it. You may write your app in any language and framework you like. Honeydocker Don’t Care

Page 19: Docker in development

P U TT I N G I T AL L T O G E T H E RI N S TA L L AT I O N G A M E

Page 20: Docker in development

I N S TAL L I N G V I RT U AL BOX• https://www.virtualbox.org/, install using `brew cask install

virtualbox`

Page 21: Docker in development

I N S TAL L I N G BO O T 2 D O C K E R

• http://boot2docker.io/, install using `brew install boot2docker`

Page 22: Docker in development

S TA RT I N G BO O T 2 D O C K E R

• Start up the Boot2Docker VM and load environment variables

Page 23: Docker in development

C O N F I R M I N G D O C K E R R U N S

• Check installation worked correctly

Page 24: Docker in development

D O C K E R F I L E

}

Build on top of a base image

Each instruction is cached

Create a working directory

Streamline using the caches

Finally, run the app

}

}}

Page 25: Docker in development

D O C K E R- C O M P O S E . Y M L

Internal name

Docker image name

What to run when it starts

Create a persistent volume

Import a volume

Expose ports (two ways)}

Page 26: Docker in development

BO O T S T RAP A PP DATA

• Start up the Boot2Docker VM and load environment variables

Page 27: Docker in development

` D O C K E R- C O M P O S E U P `

• Finally, launch your application, dependencies are booted first

Page 28: Docker in development

D E M O T I M E !L E T ’ S D O T H I S

Page 29: Docker in development

Q U E S T I O N S ?W RA P- U P