Demystifying Docker - Jugsaxony.day

Transcription

DemystifyingDockerJUG Saxony Day 2015Bernd Fischer

Who’s that guy?Passionate Java Developer (especially Spring)Agile and Devops infectedDocker UG Saxony, Docker Meetup DresdenCTO MindApproach GmbH, Dresdenbfischer@mindapproach.de

Who’s that guy?You build it you run itWerner Vogels, CTO Amazon, 2006 [Gra01]

Who’s that guy?Automate almosteverythingContinuous Delivery, 2010 [HuFa01]

AgendaDemystifying Docker .What is Docker?Dockerize a Java Web Application in five stepsLeassons learned

What is Docker

What is Docker?Container vs VMVirtual MachineContainer(Process)ContainerApp AApp BApp AApp ALibsLibsLibsLibsGuest OSDocker EngineVirtual Hardware / BIOSHypervisor / Host OSHost OSPhysical ServerPhysical Server

What is Docker?Used TechnologiesDockerLibcontainerSoftware DefinedNetworkingStorage BackendsLayered/CoW FilesystemsLinux KernelControl GroupsNamespaces

What is Docker?Images & Containerwritableempty after creationread onlymany containers can be createdbased on one image

What is Docker?DockerhubMaven Central for Docker .

What is Docker?System ArchitectureWindowsMac OS VDocker ClientDocker ClientDocker ClientRESTFul APIDocker ClientSocketDocker DaemonContainerContainerContainerDocker Host (Linux)ImagesImagesImages

What is Docker?Docker Project Family Docker-Engine (CLI Docker-Distribution)(Docker-Toolbox)(Docker Notary based on TUF)(Docker-Bench-Security)

What is Docker?Development EnvironmentMac OS XWindowsVirtual Machine ontainer

Dockerize a Java Web Application

Dockerize a Java Web AppStarting PointDemo-ApplicationJVMSpring Boot Webembedded Tomcatjava -jar .DatabaseurlusernamepasswordLinux (Ubuntu 14.04.3-LTS)

Dockerize a Java Web AppStarting PointDEMO

Dockerize a Java Web AppMySql - local Installation

Dockerize a Java Web AppMySql - local Installation

Dockerize a Java Web AppMySql - local Installation

Dockerize a Java Web AppMySql - Container

Dockerize a Java Web AppMySql - Containerdocker-machine\create\--driver virtualbox \jsd2015Docker Machine

Dockerize a Java Web AppMySql - ContainerDEMO

Dockerize a Java Web AppMySql - Container# s01-docker-compose.yamlmysql:image: mysql:5.6.26expose:- "3306"ports:- "3306:3306"environment:- MYSQL ROOT PASSWORD 9876- MYSQL USER test- MYSQL PASSWORD 1234- MYSQL DATABASE testDocker Compose

Dockerize a Java Web AppMySql - ContainerDEMO

Dockerize a Java Web AppJava - Container# s02-docker-compose.yaml (snippet)app:image: java:8ports:- "8080:8080"environment:- SPRING PROFILES ACTIVE initdbworking dir: /opt/demo-helloworld-weblinks:- mysql:mysqlentrypoint: [ "java","-Djava.security.egd file:/dev/./urandom", eb-1.0-Local.jar"]volumes:- ./././target:/opt/demo-helloworld-web:ro

Dockerize a Java Web AppJava - ContainerDEMO

Dockerize a Java Web AppUnpacked 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- - ation.yml:ro- l:ro

Dockerize a Java Web AppUnpacked Fat-JarDEMO

Dockerize a Java Web AppDocker Image by Foot# DockerfileFROM java:8MAINTAINER Bernd Fischer "bfischer@mindapproach.de"ENV MODIFIED AT 2015-09-26 1845COPY demo-helloworld-web.jar /opt/demo-helloworld-web/# mvn -PbuildDockerWorkDir# copy Dockerfile and “Fat-Jar” in separate dir# should be called from project root dirdocker build -t mapp/demo-helloworld-web04:latest \-f (pwd)/target/workdir-docker/Dockerfile \ (pwd)/target/workdir-docker

Dockerize a Java Web AppDocker Image by Foot# s04-docker-compose.yaml (snippet)app:image: mapp/demo-helloworld-web04:latestports:- "8080:8080"environment:- SPRING PROFILES ACTIVE initdbworking dir: /opt/demo-helloworld-web/links:- mysql:mysqlentrypoint: [ "java","-Djava.security.egd web/demo-helloworld-web.jar"]

Dockerize a Java Web AppDocker Image by FootDEMO

Dockerize a Java Web AppDocker 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

Dockerize a Java Web AppDocker Image by Maven# s05-docker-compose.yaml (snippet)app:image: mapp/demo-helloworld-web05:latestports:- "8080:8080"environment:- SPRING PROFILES ACTIVE initdbworking dir: /opt/demo-helloworld-web/links:- mysql:mysqlentrypoint: [ "java","-Djava.security.egd web/demo-helloworld-web.jar"]

Dockerize a Java Web AppDocker Image by MavenDEMO

Lessons learned

Lessons LearnedBereitstellung von Tools und KomponentenVerpacken und Deployen von AnwendungenEinfache Definition und Ausführung von(komplexen) dultests .

One more thing .

One more thing .Private Docker RegistriesJFrog Artifactory(Docker support commercial only)Sonatype Nexus V3.0.0CI-/CD-PipelinesJenkins-Docker-ImageJenkins Workflow Engine, Docker Plugins,

Questions ?

Thanks for attention .

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 ThroughBuild, 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 2] Docker Maven Plugin Shootout: 1] -web

Continuous Delivery, 2010 [HuFa01] Agenda Demystifying Docker . What is Docker? Dockerize a Java Web Application in five steps Leassons learned. . [HuFa01] Jez Humble, David Farley, Continuous Delivery: Reliable Software Releases Through Build, Test and Deployment Automation, 2010, Addison-Wesley