Demystifying Docker JUG Saxony Day 2015 Bernd Fischer Whos that - - PowerPoint PPT Presentation

demystifying docker
SMART_READER_LITE
LIVE PREVIEW

Demystifying Docker JUG Saxony Day 2015 Bernd Fischer Whos that - - PowerPoint PPT Presentation

Demystifying Docker JUG Saxony Day 2015 Bernd Fischer Whos that guy? Passionate Java Developer (especially Spring) Agile and Devops infected Docker enthusiast berndfischer63@gmail.com @berndfischer63 JUG Saxony, Docker Meetup Dresden


slide-1
SLIDE 1

Demystifying Docker

JUG Saxony Day 2015

Bernd Fischer

slide-2
SLIDE 2

Who’s that guy?

Passionate Java Developer (especially Spring) Agile and Devops infected Docker enthusiast berndfischer63@gmail.com @berndfischer63 JUG Saxony, Docker Meetup Dresden CTO MindApproach GmbH, Dresden bfischer@mindapproach.de

slide-3
SLIDE 3

Who’s that guy?

You build it you run it

Werner Vogels, CTO Amazon, 2006 [Gra01]

slide-4
SLIDE 4

Who’s that guy?

Automate almost everything

Continuous Delivery, 2010 [HuFa01]

slide-5
SLIDE 5

Agenda Demystifying Docker ...

What is Docker? Dockerize a Java Web Application in five steps Leassons learned

slide-6
SLIDE 6

What is Docker

slide-7
SLIDE 7

What is Docker? Container vs VM

Virtual Machine Hypervisor / Host OS Physical Server Physical Server Host OS App A App B Libs Libs Guest OS Virtual Hardware / BIOS Docker Engine Container (Process) App A Libs Container App A Libs

slide-8
SLIDE 8

What is Docker? Used Technologies

Docker Libcontainer Namespaces Control Groups Storage Backends Layered/CoW Filesystems Linux Kernel Software Defined Networking

slide-9
SLIDE 9

What is Docker? Images & Container

read only writable empty after creation many containers can be created based on one image

slide-10
SLIDE 10

What is Docker? Dockerhub

Maven Central for Docker ...

slide-11
SLIDE 11

What is Docker? System Architecture

Docker Host (Linux) Docker Client Docker Daemon Container Images Container Container Images Images Socket RESTFul API Docker Client Windows Docker Client Mac OS V Docker Client

slide-12
SLIDE 12

What is Docker? Docker Project Family

  • Docker-Engine (CLI + Daemon)
  • Docker-Machine
  • Docker-Compose
  • (Docker-Swarm)
  • (Docker-Distribution)
  • (Docker-Toolbox)
  • (Docker Notary based on TUF)
  • (Docker-Bench-Security)
slide-13
SLIDE 13

What is Docker? Development Environment

Virtual Machine (Linux) Images Container Mac OS X Windows /Users /Users Docker Client Docker Daemon

slide-14
SLIDE 14

Dockerize a Java Web Application

slide-15
SLIDE 15

Dockerize a Java Web App Starting Point

Linux (Ubuntu 14.04.3-LTS)

java -jar ... url username password

JVM Demo-Application

Spring Boot Web embedded Tomcat

Database

slide-16
SLIDE 16

Dockerize a Java Web App Starting Point

DEMO

slide-17
SLIDE 17

Dockerize a Java Web App MySql - local Installation

slide-18
SLIDE 18

Dockerize a Java Web App MySql - local Installation

slide-19
SLIDE 19

Dockerize a Java Web App MySql - local Installation

slide-20
SLIDE 20

Dockerize a Java Web App MySql - Container

slide-21
SLIDE 21

Dockerize a Java Web App MySql - Container

Docker Machine

docker-machine \ create \

  • -driver=virtualbox \

jsd2015

slide-22
SLIDE 22

Dockerize a Java Web App MySql - Container

DEMO

slide-23
SLIDE 23

Dockerize a Java Web App MySql - Container

Docker Compose

# s01-docker-compose.yaml mysql: image: mysql:5.6.26 expose:

  • "3306"

ports:

  • "3306:3306"

environment:

  • MYSQL_ROOT_PASSWORD=9876
  • MYSQL_USER=test
  • MYSQL_PASSWORD=1234
  • MYSQL_DATABASE=test
slide-24
SLIDE 24

Dockerize a Java Web App MySql - Container

DEMO

slide-25
SLIDE 25

Dockerize a Java Web App Java - Container

# s02-docker-compose.yaml (snippet) app: image: java:8 ports:

  • "8080:8080"

environment:

  • SPRING_PROFILES_ACTIVE=initdb

working_dir: /opt/demo-helloworld-web links:

  • mysql:mysql

entrypoint: [ "java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "/opt/demo-helloworld-web/demo-helloworld-web-1.0-Local.jar" ] volumes:

  • ../../../target:/opt/demo-helloworld-web:ro
slide-26
SLIDE 26

Dockerize a Java Web App Java - Container

DEMO

slide-27
SLIDE 27

Dockerize a Java Web App Unpacked Fat-Jar

# maven -PunzipFatJar # unzip target/demo-helloworld-web-1.0-Local.jar \

  • d target/app

# s03-docker-compose.yaml (snippet) app: # ... volumes:

  • ../../../target/app/META-INF:/opt/.../META-INF:ro
  • ../../../target/classes/de:/opt/.../de:ro
  • ../../../target/app/lib:/opt/.../lib:ro
  • ../../../target/app/org:/opt/.../org:ro
  • ../../../target/classes/static:/opt/.../static:ro
  • ../../../target/classes/templates:/opt/.../templates:ro
  • ../../../target/classes/application.yml:/opt/.../application.yml:ro
  • ../../../target/classes/logback.xml:/opt/.../logback.xml:ro
slide-28
SLIDE 28

Dockerize a Java Web App Unpacked Fat-Jar

DEMO

slide-29
SLIDE 29

Dockerize a Java Web App Docker Image by Foot

# Dockerfile FROM java:8 MAINTAINER Bernd Fischer "bfischer@mindapproach.de" ENV MODIFIED_AT 2015-09-26_1845 COPY demo-helloworld-web.jar /opt/demo-helloworld-web/ # mvn -PbuildDockerWorkDir # copy Dockerfile and “Fat-Jar” in separate dir # should be called from project root dir docker build -t mapp/demo-helloworld-web04:latest \

  • f $(pwd)/target/workdir-docker/Dockerfile \

$(pwd)/target/workdir-docker

slide-30
SLIDE 30

Dockerize a Java Web App Docker Image by Foot

# s04-docker-compose.yaml (snippet) app: image: mapp/demo-helloworld-web04:latest ports:

  • "8080:8080"

environment:

  • SPRING_PROFILES_ACTIVE=initdb

working_dir: /opt/demo-helloworld-web/ links:

  • mysql:mysql

entrypoint: [ "java", "-Djava.security.egd=file:/dev/./urandom", "-jar","/opt/demo-helloworld-web/demo-helloworld-web.jar" ] _________

slide-31
SLIDE 31

Dockerize a Java Web App Docker Image by Foot

DEMO

slide-32
SLIDE 32

Dockerize a Java Web App Docker Image by Maven

# Maven (snippet) <plugin> <groupId>org.jolokia</groupId> <artifactId>docker-maven-plugin</artifactId> <version>0.13.4</version> <configuration> <dockerHost>${env.DOCKER_HOST}</dockerHost> <certPath>${env.DOCKER_CERT_PATH}</certPath> <images> <image> <name>mapp/demo-helloworld-web05</name> ... </image> </images> </configuration> ... </plugin>

slide-33
SLIDE 33

Dockerize a Java Web App Docker Image by Maven

# s05-docker-compose.yaml (snippet) app: image: mapp/demo-helloworld-web05:latest ports:

  • "8080:8080"

environment:

  • SPRING_PROFILES_ACTIVE=initdb

working_dir: /opt/demo-helloworld-web/ links:

  • mysql:mysql

entrypoint: [ "java", "-Djava.security.egd=file:/dev/./urandom", "-jar","/opt/demo-helloworld-web/demo-helloworld-web.jar" ]

slide-34
SLIDE 34

Dockerize a Java Web App Docker Image by Maven

DEMO

slide-35
SLIDE 35

Lessons learned

slide-36
SLIDE 36

Lessons Learned

Bereitstellung von Tools und Komponenten Verpacken und Deployen von Anwendungen Einfache Definition und Ausführung von (komplexen) Anwendungslandschaften (“Compositions”) Unit-/Modultests ...

slide-37
SLIDE 37

One more thing ...

slide-38
SLIDE 38

One more thing ….

Private Docker Registries

JFrog Artifactory (Docker support commercial only) Sonatype Nexus V3.0.0

CI-/CD-Pipelines

Jenkins-Docker-Image Jenkins Workflow Engine, Docker Plugins, …

slide-39
SLIDE 39

Questions … ?

slide-40
SLIDE 40

Thanks for attention ...

slide-41
SLIDE 41

Links ...

  • [Gra01] J. Gray, A Conversation with Werner Vogels: Learning form the Amazon technology

platform, 2006, siehe: https://queue.acm.org/detail.cfm?id=1142065

  • [HuFa01] Jez Humble, David Farley, Continuous Delivery: Reliable Software Releases Through

Build, Test and Deployment Automation, 2010, Addison-Wesley

  • [Do01] Docker Homepage https://www.docker.com/
  • [Do02] Docker Hub https://hub.docker.com/
  • [Do03] Docker Engine https://github.com/docker/docker
  • [Do04] Docker Machine https://github.com/docker/machine
  • [Do05] Docker Compose https://github.com/docker/compose
  • [Do06] Docker Toolbox https://github.com/docker/toolbox
  • [Http01] Httpie Homepage http://httpie.org/
  • [RHu01] Docker-Maven-Plugin https://github.com/rhuss/docker-maven-plugin
  • [RHus02] Docker Maven Plugin Shootout: https://github.com/rhuss/shootout-docker-maven
  • [Ma01] https://bitbucket.org/mindapproach/demo-helloworld-web