Using Docker to deliver Java Enterprise Applications one year later… Petyo Dimitrov May 26-27 ‘16, Sofia
26-27/05/2016
Slide 2
Agenda • What problems we had? • Docker introduction
• How to “dockerize” a sample application? • Docker technologies
• What about VMs? • Lessons learnt…. 26-27/05/2016
2 / 34
Slide 3
problems
26-27/05/2016
3 / 34
Slide 4
inadequate packaging of application artifacts
26-27/05/2016
4 / 34
Slide 5
inconsistencies across environments 26-27/05/2016
5 / 34
Slide 6
high cost supporting multiple static environments
26-27/05/2016
6 / 34
Slide 7
lack of freedom experimenting with new languages, technologies and frameworks 26-27/05/2016
7 / 34
Slide 8
Sea-free analogy
26-27/05/2016
8 / 34
Slide 9
Developers
Operations
• care about apps
• care about containers
• put stuff in containers
• work with containers
• code & data
• logging & monitoring
• libraries
• networking
• applications
• scaling
26-27/05/2016
9 / 34
Slide 10
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 26-27/05/2016
10 / 34
Slide 11
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 26-27/05/2016
11 / 34
Standard Java application build
26-27/05/2016
16 / 34
Slide 17
Docker containers build
26-27/05/2016
17 / 34
Slide 18
Adding system testing
26-27/05/2016
18 / 34
Slide 19
Combining all the parts
26-27/05/2016
19 / 34
Slide 20
Demonstration
26-27/05/2016
20 / 34
Slide 21
Docker “ecosystem”
26-27/05/2016
21 / 34
Slide 22
Client-Server model
26-27/05/2016
22 / 34
Slide 23
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) 26-27/05/2016
23 / 34
Slide 24
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 26-27/05/2016
24 / 34
Slide 25
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 26-27/05/2016
25 / 34
Slide 26
Virtual machines
26-27/05/2016
vs.
Containers
26 / 34
Slide 27
Comparison with VMs
https://github.com/petyodimitrov/ci-setup.git https://github.com/petyodimitrov/vagrant-setup.git https://github.com/petyodimitrov/vm-container-comparison.git 26-27/05/2016
27 / 34
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) 26-27/05/2016
31 / 34
Slide 32
Lessons learnt (2) • Review Dockerfile-s as part of development process (e.g. peer reviews) 14.04.3 FROM alpine-java ubuntu:latest ENV REPO=10.0.1.1:1236
verify checksum
RUN apt-get && \ RUN apt-getupdate update–y–y curl RUN apt-get apt-getinstall install curl –y # unnecessary RUN apt-get install wget -y https ${REPO} RUN curl -L http://10.0.1.1:1236/something.jar USER nobody USER ROOT CMD java –jar something.jar
add volume 26-27/05/2016
32 / 34
Slide 33
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… 26-27/05/2016
33 / 34
Slide 34
THANK YOU :) You can find me at: petyo.dimitrov@gmail.com
Petyo Dimitrov May 26-27 ’16, Sofia
26-27/05/2016