Achieving Continuous Delivery with Docker for Java Enterprise applications
Petyo Dimitrov | Musala Soft JSC
18-19 November, Sofia
Slide 2
Agenda • • • • • • • 2/38
A typical Enterprise Java landscape Continuous Delivery pipeline Identified problems What are Docker containers? Docker “ecosystem” Demo Tips & Tricks 18-19 November, Sofia
Slide 3
Dev landscape for Java EE applications
3/38
18-19 November, Sofia
Slide 4
Continuous Delivery pipeline
4/38
18-19 November, Sofia
Slide 5
potential issues 5/38
18-19 November, Sofia
Slide 6
inadequate packaging of application artifacts
6/38
18-19 November, Sofia
Slide 7
inconsistencies across environments 7/38
18-19 November, Sofia
Slide 8
high cost supporting multiple static environments
8/38
18-19 November, Sofia
Slide 9
lack of freedom experimenting with new languages, technologies and frameworks 9/38
18-19 November, Sofia
Slide 10
how can docker containers help?
10/38
wait…what… containers?
18-19 November, Sofia
Slide 11
getting sea sick here!!!
11/38
18-19 November, Sofia
Slide 12
sea-free analogy 12/38
18-19 November, Sofia
Slide 13
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 13/38
18-19 November, Sofia
Slide 14
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 14/38
18-19 November, Sofia
Slide 15
Virtual machines vs Containers
15/38
18-19 November, Sofia
.
Slide 16
How does it work? – Isolation • isolation via namespaces • pid, mnt, net, uts, user, ipc
• isolation via control groups • memory, cpu, blkio, devices 16/38
18-19 November, Sofia
Slide 17
How does it work? – Storage • union file system (aufs, overlayfs) • allows reusing common layers • reduces traffic and storage
• allows tracking changes • copy-on-write pattern used for speed 17/38
18-19 November, Sofia
Slide 18
Developers
Operations
• care about apps
• care about containers
• put stuff in containers
• work with containers
• code & data
• logging & monitoring
• libraries
• networking
• applications
• scaling
18/38
18-19 November, Sofia
Slide 19
docker “ecosystem”
19/38
18-19 November, Sofia
Slide 20
Client-Server model
20/38
18-19 November, Sofia
Slide 21
Docker engine • runs and commoditizes Linux containers • uses copy-on-write for quick provisioning • runs as daemon and has CLI • allows building and sharing images • functionality is exposed via REST API
• defines standard format for containers 21/38
18-19 November, Sofia
Slide 22
Docker commands • ~40 commands • for working with: • images • containers
• registry 22/38
18-19 November, Sofia
Slide 23
Dockerfile-s FROM jenkins:1.625.1 MAINTAINER Petyo Dimitrov ENV REFRESHED_AT 2015-10-24 RUN curl -L https://github.com/… > /usr/local/bin/docker-compose && chmod +x /usr/local/bin/docker-compose RUN mkdir /var/cache/jenkins RUN chown -R jenkins:jenkins /var/cache/jenkins
docker build –t myjenkins .
Set Defaults ENV JAVA_OPTS=”-Xmx6144m” ENV JENKINS_OPTS=”—handlerCountMax=300 —webroot=/var/cache/jenkins/war”
COPY plugins.txt /plugins.txt RUN /usr/local/bin/plugins.sh /plugins.txt 23/38
18-19 November, Sofia
Slide 24
Docker Hub/Registry • collection of ready-made images • options: • public/private registry • local registry • REST API for access 24/38
18-19 November, Sofia
Slide 25
But how to build a stack of containers? 25/38
18-19 November, Sofia
Slide 26
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/38
18-19 November, Sofia
Slide 27
YAML example
27/38
18-19 November, Sofia
Slide 28
How can I quickly provision a Docker host? 28/38
18-19 November, Sofia
Slide 29
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 29/38
18-19 November, Sofia
Slide 30
Docker Summary • put my software in containers • run those containers anywhere • write recipes to automatically build containers 30/38
18-19 November, Sofia
Slide 31
Demonstration https://github.com/petyodimitrov/spring-music.git https://github.com/petyodimitrov/app-setup.git https://github.com/petyodimitrov/ci-setup.git 31/38
18-19 November, Sofia
Slide 32
Standard Java application build
2
1
32/38
18-19 November, Sofia
Runtime view of containers
34/38
18-19 November, Sofia
Slide 35
Demonstration
35/38
18-19 November, Sofia
Slide 36
36/38
18-19 November, Sofia
Slide 37
Tips & Tricks • • • • • 37/38
single process per container security considerations use data containers for portability consider reducing image sizes etc… 18-19 November, Sofia