Demystifying Docker JUG Saxony Day 2015 Bernd Fischer
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
Who’s that guy? You build it you run it Werner Vogels, CTO Amazon, 2006 [Gra01]
Who’s that guy? Automate almost everything Continuous Delivery, 2010 [HuFa01]
Agenda Demystifying Docker ... What is Docker? Dockerize a Java Web Application in five steps Leassons learned
What is Docker
What is Docker? Container vs VM Container Container Virtual Machine (Process) App A App B App A App A Libs Libs Libs Libs Guest OS Docker Engine Virtual Hardware / BIOS Hypervisor / Host OS Host OS Physical Server Physical Server
What is Docker? Used Technologies Docker Libcontainer Software Defined Storage Backends Control Groups Namespaces Networking Layered/CoW Filesystems Linux Kernel
What is Docker? Images & Container writable empty after creation read only many containers can be created based on one image
What is Docker? Dockerhub Maven Central for Docker ...
What is Docker? System Architecture Windows Mac OS V Docker Client Docker Client Docker Client RESTFul API Socket Docker Client Docker Daemon Container Images Container Images Container Images Docker Host (Linux)
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)
What is Docker? Development Environment Mac OS X Windows Virtual Machine (Linux) Docker Docker Client Daemon Images /Users /Users Container
Dockerize a Java Web Application
Dockerize a Java Web App Starting Point Demo-Application Spring Boot Web JVM Database embedded Tomcat url username java -jar ... password Linux (Ubuntu 14.04.3-LTS)
Dockerize a Java Web App Starting Point DEMO
Dockerize a Java Web App MySql - local Installation
Dockerize a Java Web App MySql - local Installation
Dockerize a Java Web App MySql - local Installation
Dockerize a Java Web App MySql - Container
Dockerize a Java Web App MySql - Container docker-machine \ create \ --driver=virtualbox \ jsd2015 Docker Machine
Dockerize a Java Web App MySql - Container DEMO
Dockerize a Java Web App MySql - Container # 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 Docker Compose
Dockerize a Java Web App MySql - Container DEMO
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
Dockerize a Java Web App Java - Container DEMO
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
Dockerize a Java Web App Unpacked Fat-Jar DEMO
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
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" ] _________
Dockerize a Java Web App Docker Image by Foot DEMO
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>
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" ]
Dockerize a Java Web App Docker Image by Maven DEMO
Lessons learned
Lessons Learned Bereitstellung von Tools und Komponenten Verpacken und Deployen von Anwendungen Einfache Definition und Ausführung von (komplexen) Anwendungslandschaften (“Compositions”) Unit-/Modultests ...
One more thing ...
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, …
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 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
Recommend
More recommend