Slide 1

Slide 1 text

Docker & JVM A Perfect Match Matthias Grüter // @mattgruter Jfokus 2015

Slide 2

Slide 2 text

Image Credit: Tim Kirman

Slide 3

Slide 3 text

Image Credit: Tim Kirman

Slide 4

Slide 4 text

Your Toastmaster Matthias Grüter

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

Containers Credit: containersfirst.com.au

Slide 7

Slide 7 text

VM Container

Slide 8

Slide 8 text

Shipping Containers Credit: danielpivnick

Slide 9

Slide 9 text

Build, Ship and Run Any App, Anywhere

Slide 10

Slide 10 text

Let's create some containers!

Slide 11

Slide 11 text

Container Networking

Slide 12

Slide 12 text

Ports to the outside world d o c k e r r u n ­ p 9 0 0 0 : 8 0 8 0 . . . F o r m a t : [ h o s t P o r t ] : [ c o n t a i n e r P o r t ]

Slide 13

Slide 13 text

Container Linking 1. Database container "redis1" d o c k e r r u n ­ ­ n a m e r e d i s 1 r e d i s 2. Application container "myapp" (wants DB backend) d o c k e r r u n ­ ­ l i n k r e d i s 1 : d b m y a p p F o r m a t : ­ ­ l i n k [ c o n t a i n e r N a m e ] : [ a l i a s ]

Slide 14

Slide 14 text

Docker Images Container Blueprints Source: homeinabox.blogspot.se

Slide 15

Slide 15 text

Layered Filesystems

Slide 16

Slide 16 text

Sharing Images

Slide 17

Slide 17 text

Creating Images

Slide 18

Slide 18 text

Example: Jenkins F R O M d e b i a n : j e s s i e # i n s t a l l j a v a R U N a p t ­ g e t u p d a t e & & a p t ­ g e t i n s t a l l ­ y o p e n j d k ­ 7 ­ j r e # i n s t a l l j e n k i n s A D D h t t p : / / m i r r o r s . j e n k i n s ­ c i . o r g / w a r / 1 . 5 9 7 / j e n k i n s . w a r / E N V J E N K I N S _ H O M E / j e n k i n s W O R K D I R / j e n k i n s E X P O S E 8 0 8 0 C M D [ " j a v a " , " ­ j a r " , " / j e n k i n s . w a r " ]

Slide 19

Slide 19 text

Example: Jenkins Build: d o c k e r b u i l d ­ ­ t a g j e n k i n s . Run: d o c k e r r u n ­ p 8 0 8 0 : 8 0 8 0 j e n k i n s

Slide 20

Slide 20 text

Data Volumes Expose: d o c k e r r u n ­ v / d a t a ­ ­ n a m e d b r e d i s Access: d o c k e r r u n ­ ­ v o l u m e s ­ f r o m = d b r s y n c ­ r / d a t a / r e m o t e : / b a c k u p Credit: Tony Cole

Slide 21

Slide 21 text

A Perfect Match

Slide 22

Slide 22 text

Image credit: snorgtees.com

Slide 23

Slide 23 text

Docker and the JVM Encapsulation (app + libs) Memory management Portability Encapsulation (runtime) Isolation & Containment Portability

Slide 24

Slide 24 text

Docker and the JVM Encapsulation Sandboxing Portability

Slide 25

Slide 25 text

Ecosystem Docker API Build system Build/CI servers Build repositories ...

Slide 26

Slide 26 text

Wedding Gift

Slide 27

Slide 27 text

Qubit‐Coins

Slide 28

Slide 28 text

The Grand Scheme

Slide 29

Slide 29 text

Webapp Gradle p l u g i n s { i d ' a p p l i c a t i o n ' } m a i n C l a s s N a m e = ' s e . q u b i t . w e b a p p . M a i n ' g r o u p = ' m a t t g r u t e r ' r e p o s i t o r i e s { j c e n t e r ( ) } d e p e n d e n c i e s { . . . }

Slide 30

Slide 30 text

Webapp Gradle & Docker p l u g i n s { i d ' a p p l i c a t i o n ' i d ' s e . t r a n s m o d e . d o c k e r ' v e r s i o n ' 1 . 3 ' } m a i n C l a s s N a m e = ' s e . q u b i t . w e b a p p . M a i n ' g r o u p = ' m a t t g r u t e r ' r e p o s i t o r i e s { j c e n t e r ( ) } d e p e n d e n c i e s { . . . } d i s t D o c k e r . d o c k e r f i l e { E X P O S E 8 0 8 0 }

Slide 31

Slide 31 text

Build g r a d l e d i s t D o c k e r :‐)

Slide 32

Slide 32 text

Deploy Wallet (Redis) d o c k e r r u n ­ d ­ ­ n a m e d b r e d i s Miner d o c k e r r u n ­ d ­ ­ l i n k d b : d b m a t t g r u t e r / q u b i t ­ m i n e r Webapp d o c k e r r u n ­ ­ l i n k d b : d b ­ p 8 0 8 0 : 8 0 8 0 m a t t g r u t e r / q u b i t ­ w e b a p p

Slide 33

Slide 33 text

Faster! d o c k e r r u n ­ d ­ ­ l i n k d b : d b m a t t g r u t e r / q u b i t ­ m i n e r d o c k e r r u n ­ d ­ ­ l i n k d b : d b m a t t g r u t e r / q u b i t ­ m i n e r d o c k e r r u n ­ d ­ ­ l i n k d b : d b m a t t g r u t e r / q u b i t ­ m i n e r . . .

Slide 34

Slide 34 text

Image credit: Deep Impact

Slide 35

Slide 35 text

Your container is NOT a VM Stop treating it like one!

Slide 36

Slide 36 text

Corollary #1 Say no to s s h d use volumes, volumes, volumes ... and docker exec

Slide 37

Slide 37 text

Corollary #2 There can be only one PID Credit: imaginarywars.wordpress.com

Slide 38

Slide 38 text

Docker is a polyglot tool! So sorry, JVM!

Slide 39

Slide 39 text

Docker Hub Automated Builds

Slide 40

Slide 40 text

Be Specific Images are cheap, therefore ... ... build many small specific images.

Slide 41

Slide 41 text

Size Matters Use small baseimages

Slide 42

Slide 42 text

Corollary (e.g. apt‐get clean, multi‐line run)

Slide 43

Slide 43 text

Use the cache, Luke! Move ADD & COPY to end of Dockerfile (they invalidate the cache)

Slide 44

Slide 44 text

What does the future hold? Credit: www.clipartbest.com/8balllogo

Slide 45

Slide 45 text

Image Credit: Tim Kirman

Slide 46

Slide 46 text

Credit: Solomon Hykes

Slide 47

Slide 47 text

No content