Docker & JVM: A Perfect Match

Docker & JVM: A Perfect Match

A brief introduction to the concepts behind Docker and a handful of tips to get you started on the exciting journey towards a more robust and reliable application deployment. You will learn how to build and deploy Docker images, how to let your containers talk to each other and why the JVM and Docker are a perfect match.

(Slides from my Jfokus 2015 talk)

Matthias Grüter

February 04, 2015

Annual Pro sale · Save $30

Have presentations of your own?

Share with private links, password protection, and more control over your work.

Transcript

47 slides
  1. 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 ]
  2. 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 ]
  3. 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 " ]
  4. 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
  5. 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
  6. Docker and the JVM Encapsulation (app + libs) Memory management

    Portability Encapsulation (runtime) Isolation & Containment Portability
  7. 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 { . . . }
  8. 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 }
  9. Build g r a d l e d i s

    t D o c k e r :‐)
  10. 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
  11. 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 . . .
  12. Corollary #1 Say no to s s h d use

    volumes, volumes, volumes ... and docker exec
  13. Use the cache, Luke! Move ADD & COPY to end

    of Dockerfile (they invalidate the cache)

More Decks by Matthias Grüter

Other Decks in Programming