Achieving Continuous Delivery of Java Enterprise applications with Docker Petyo Dimitrov
Slide 2
Agenda • • • • • • •
A typical Enterprise Java landscape Continuous Delivery pipeline Identified problems What are Docker containers? Docker “ecosystem” Demo Tips & Tricks 08.10.2016
2
Slide 3
Dev landscape for Java EE applications
08.10.2016
3
Slide 4
Continuous Delivery pipeline
08.10.2016
4
Slide 5
problems 08.10.2016
5
Slide 6
inadequate packaging of application artifacts
08.10.2016
6
Slide 7
inconsistencies across environments 08.10.2016
7
Slide 8
high cost supporting multiple static environments
08.10.2016
8
Slide 9
lack of freedom experimenting with new languages, technologies and frameworks 08.10.2016
9
Slide 10
docker 08.10.2016
10
Slide 11
08.10.2016
11
Slide 12
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 08.10.2016
12
Slide 13
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 08.10.2016
13
Slide 14
Virtual machines vs Containers
08.10.2016
14
Slide 15
How does it work? - Isolation • isolation via namespaces – pid, mnt, net, uts, user, ipc
• isolation via control groups – memory, cpu, blkio, devices 08.10.2016
15
Slide 16
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 08.10.2016
16
Slide 17
Developers • care about applications • put stuff in containers – code & data – libraries – applications
Operations • care about containers • work with containers – logging & monitoring – networking – scaling
08.10.2016
17
Slide 18
docker “ecosystem”
08.10.2016
18
Slide 19
Client-Server model
08.10.2016
19
Slide 20
Docker engine • runs and commoditizes Linux containers • uses copy-on-write for quick provisioning • runs as daemon and has CLI • allows building & sharing images • functionality is exposed via REST API • defines standard format for containers 08.10.2016
20
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 08.10.2016
22
Slide 23
Docker Compose • manages a collection of containers • fast, isolated development environments using Docker • define env via YAML file • quick and easy to start
docker-compose up –d 08.10.2016
23
Tips & tricks (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) 08.10.2016
32
Slide 33
Tips & tricks (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 RUN RUN apt-get apt-get update update –y –y && \ apt-get install curl RUN apt-get install curl –y # unnecessary RUN apt-get install wget -y verify checksum
RUN curl -L
https ${REPO} http://10.0.1.1:1236/something.jar
USER USERROOT nobody
CMD java –jar something.jar 08.10.2016
33
Slide 34
petyo.dimitrov @musala.com
08.10.2016
Achieving Continuous Delivery of Java Enterprise applications with Docker
34