using docker to deliver java enterprise applications - jug.bg docker to deliver java... · docker...

34
26-27/05/2016 Using Docker to deliver Java Enterprise Applications one year later… Petyo Dimitrov May 26-27 ‘16, Sofia

Upload: vuongnhu

Post on 13-Jan-2019

232 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Using Docker to deliver Java Enterprise Applications - jug.bg Docker to deliver Java... · Docker Machine •allows creating Docker hosts on local computer or in cloud providers •automatically

26-27/05/2016

Using Docker to deliver

Java Enterprise Applications

one year later…

Petyo Dimitrov May 26-27 ‘16, Sofia

Page 2: Using Docker to deliver Java Enterprise Applications - jug.bg Docker to deliver Java... · Docker Machine •allows creating Docker hosts on local computer or in cloud providers •automatically

26-27/05/2016

Agenda

• What problems we had?

• Docker introduction

• How to "dockerize" a sample application?

• Docker technologies

• What about VMs?

• Lessons learnt….

2 / 34

Page 3: Using Docker to deliver Java Enterprise Applications - jug.bg Docker to deliver Java... · Docker Machine •allows creating Docker hosts on local computer or in cloud providers •automatically

26-27/05/2016

problems

3 / 34

Page 4: Using Docker to deliver Java Enterprise Applications - jug.bg Docker to deliver Java... · Docker Machine •allows creating Docker hosts on local computer or in cloud providers •automatically

26-27/05/2016

inadequate packaging of application artifacts

4 / 34

Page 5: Using Docker to deliver Java Enterprise Applications - jug.bg Docker to deliver Java... · Docker Machine •allows creating Docker hosts on local computer or in cloud providers •automatically

26-27/05/2016

inconsistencies across environments 5 / 34

Page 6: Using Docker to deliver Java Enterprise Applications - jug.bg Docker to deliver Java... · Docker Machine •allows creating Docker hosts on local computer or in cloud providers •automatically

26-27/05/2016

high cost supporting multiple static environments

6 / 34

Page 7: Using Docker to deliver Java Enterprise Applications - jug.bg Docker to deliver Java... · Docker Machine •allows creating Docker hosts on local computer or in cloud providers •automatically

26-27/05/2016

lack of freedom

experimenting with new languages,

technologies and frameworks

7 / 34

Page 8: Using Docker to deliver Java Enterprise Applications - jug.bg Docker to deliver Java... · Docker Machine •allows creating Docker hosts on local computer or in cloud providers •automatically

26-27/05/2016

Sea-free analogy

8 / 34

Page 9: Using Docker to deliver Java Enterprise Applications - jug.bg Docker to deliver Java... · Docker Machine •allows creating Docker hosts on local computer or in cloud providers •automatically

26-27/05/2016

Developers Operations

• care about apps

• put stuff in containers

• code & data

• libraries

• applications

• care about containers

• work with containers

• logging & monitoring

• networking

• scaling

9 / 34

Page 10: Using Docker to deliver Java Enterprise Applications - jug.bg Docker to deliver Java... · Docker Machine •allows creating Docker hosts on local computer or in cloud providers •automatically

26-27/05/2016

High level view of a container

• it is like a lightweight Virtual Machine

• it provides:

•own process space

•own network interface

• running stuff as root

10 / 34

Page 11: Using Docker to deliver Java Enterprise Applications - jug.bg Docker to deliver Java... · Docker Machine •allows creating Docker hosts on local computer or in cloud providers •automatically

26-27/05/2016

Low level view of a container

•container = "process in a box"

• shares kernel with host boots faster

•processes run directly on the host

• there is no device emulation

•none or little CPU, memory, network

and I/O overhead

11 / 34

Page 12: Using Docker to deliver Java Enterprise Applications - jug.bg Docker to deliver Java... · Docker Machine •allows creating Docker hosts on local computer or in cloud providers •automatically

26-27/05/2016

Fast forward one year

12 / 34

Page 14: Using Docker to deliver Java Enterprise Applications - jug.bg Docker to deliver Java... · Docker Machine •allows creating Docker hosts on local computer or in cloud providers •automatically

26-27/05/2016

Used technologies

14 / 34

Page 15: Using Docker to deliver Java Enterprise Applications - jug.bg Docker to deliver Java... · Docker Machine •allows creating Docker hosts on local computer or in cloud providers •automatically

26-27/05/2016

Runtime view of containers

15 / 34

Page 16: Using Docker to deliver Java Enterprise Applications - jug.bg Docker to deliver Java... · Docker Machine •allows creating Docker hosts on local computer or in cloud providers •automatically

26-27/05/2016

Standard Java application build

16 / 34

Page 17: Using Docker to deliver Java Enterprise Applications - jug.bg Docker to deliver Java... · Docker Machine •allows creating Docker hosts on local computer or in cloud providers •automatically

26-27/05/2016

Docker containers build

17 / 34

Page 18: Using Docker to deliver Java Enterprise Applications - jug.bg Docker to deliver Java... · Docker Machine •allows creating Docker hosts on local computer or in cloud providers •automatically

26-27/05/2016

Adding system testing

18 / 34

Page 19: Using Docker to deliver Java Enterprise Applications - jug.bg Docker to deliver Java... · Docker Machine •allows creating Docker hosts on local computer or in cloud providers •automatically

26-27/05/2016

Combining all the parts

19 / 34

Page 20: Using Docker to deliver Java Enterprise Applications - jug.bg Docker to deliver Java... · Docker Machine •allows creating Docker hosts on local computer or in cloud providers •automatically

26-27/05/2016

Demonstration

20 / 34

Page 21: Using Docker to deliver Java Enterprise Applications - jug.bg Docker to deliver Java... · Docker Machine •allows creating Docker hosts on local computer or in cloud providers •automatically

26-27/05/2016

Docker "ecosystem"

21 / 34

Page 22: Using Docker to deliver Java Enterprise Applications - jug.bg Docker to deliver Java... · Docker Machine •allows creating Docker hosts on local computer or in cloud providers •automatically

26-27/05/2016

Client-Server model

22 / 34

Page 23: Using Docker to deliver Java Enterprise Applications - jug.bg Docker to deliver Java... · Docker Machine •allows creating Docker hosts on local computer or in cloud providers •automatically

26-27/05/2016

Docker Engine

• runs and commoditizes Linux containers

• allows building and sharing images

• runs as daemon and has CLI

• functionality is exposed via REST API

• moves towards standardization

(runC, containerd)

23 / 34

Page 24: Using Docker to deliver Java Enterprise Applications - jug.bg Docker to deliver Java... · Docker Machine •allows creating Docker hosts on local computer or in cloud providers •automatically

26-27/05/2016

Docker Compose

• manages a collection of containers

• fast, isolated development

environments using Docker

• define environment via YAML file

• quick and easy to start

docker-compose up –d

24 / 34

Page 25: Using Docker to deliver Java Enterprise Applications - jug.bg Docker to deliver Java... · Docker Machine •allows creating Docker hosts on local computer or in cloud providers •automatically

26-27/05/2016

Docker Machine

• allows creating Docker hosts on local computer

or in cloud providers

• automatically creates host, installs

Docker and configures the client

• offers commands to start, stop,

restart and inspect a host

docker-machine create

--driver virtualbox default

25 / 34

Page 26: Using Docker to deliver Java Enterprise Applications - jug.bg Docker to deliver Java... · Docker Machine •allows creating Docker hosts on local computer or in cloud providers •automatically

26-27/05/2016

Virtual machines vs. Containers

26 / 34

Page 28: Using Docker to deliver Java Enterprise Applications - jug.bg Docker to deliver Java... · Docker Machine •allows creating Docker hosts on local computer or in cloud providers •automatically

26-27/05/2016

Application delivery time

τdelivery (сек.) virtualization containers

τ package 25,6 29,6

τ setup 512,8 29,2

τ startup 163,6 16,4

τ test 22,8 11

τ shutdown 23,4 1,4

τ cleanup 12,4 2,8

total 760,6 90,4

28 / 34

Page 29: Using Docker to deliver Java Enterprise Applications - jug.bg Docker to deliver Java... · Docker Machine •allows creating Docker hosts on local computer or in cloud providers •automatically

26-27/05/2016

Application delivery time (2)

29 / 34

Page 30: Using Docker to deliver Java Enterprise Applications - jug.bg Docker to deliver Java... · Docker Machine •allows creating Docker hosts on local computer or in cloud providers •automatically

26-27/05/2016

Performance benchmarks (cpu, memory, net)

• CPU performance [MFLOPS]: 2%

• Compression speed [MB/s]: 11%

• Memory bandwidth [MB/s]: 3%

• Serial/Parallel memory access speed [MB/s]: 19%

• Network efficiency [Mbps] & latency [μs]: ?

• Privisioning speed [s]: 60 times

average improvement

with containers

30 / 34

Page 31: Using Docker to deliver Java Enterprise Applications - jug.bg Docker to deliver Java... · Docker Machine •allows creating Docker hosts on local computer or in cloud providers •automatically

26-27/05/2016

Lessons learnt (1)

• Decide on a strategy for introducing Docker in the project

• Keep and eye for improvements & changes (e.g. networks)

• Keep containers simple (i.e. only one/few processes)

• Automate, automate, automate … (via docker or other CM tools)

• Use initialization & validation scripts (e.g. init, supervisord)

31 / 34

Page 32: Using Docker to deliver Java Enterprise Applications - jug.bg Docker to deliver Java... · Docker Machine •allows creating Docker hosts on local computer or in cloud providers •automatically

26-27/05/2016

Lessons learnt (2)

• Review Dockerfile-s as part of development process (e.g. peer reviews)

FROM ubuntu:latest

RUN apt-get update –y

RUN apt-get install curl –y

RUN apt-get install wget -y

RUN curl -L http://10.0.1.1:1236/something.jar

USER ROOT

CMD java –jar something.jar

14.04.3

https verify

checksum USER nobody

alpine-java

ENV REPO=10.0.1.1:1236

${REPO}

# unnecessary

RUN apt-get update –y && \

apt-get install curl

add volume

32 / 34

Page 33: Using Docker to deliver Java Enterprise Applications - jug.bg Docker to deliver Java... · Docker Machine •allows creating Docker hosts on local computer or in cloud providers •automatically

26-27/05/2016

Lessons learnt (3)

• Use internal Docker registry for image distribution (unless OSS)

• Invest time to setup container monitoring (e.g. logspout + ELK)

• Consider using JARs instead of other *ARs

• Shared Docker pattern overall works better than DinD

• to be continued…

33 / 34

Page 34: Using Docker to deliver Java Enterprise Applications - jug.bg Docker to deliver Java... · Docker Machine •allows creating Docker hosts on local computer or in cloud providers •automatically

26-27/05/2016

THANK YOU :)

You can find me at: [email protected]

Petyo Dimitrov May 26-27 ’16, Sofia