Share
Embed
Demystifying Docker
Talk at JUG Saxony Day Dresden 2015-10-02 (http://www.jug-saxony-day.org)
berndfischer63
October 02, 2015
Transcript
41 slides
-
Who’s that guy? Passionate Java Developer (especially Spring) Agile and
Devops infected Docker enthusiast [email protected] @berndfischer63 JUG Saxony, Docker Meetup Dresden CTO MindApproach GmbH, Dresden [email protected] -
Who’s that guy? You build it you run it Werner
Vogels, CTO Amazon, 2006 [Gra01] -
Agenda Demystifying Docker ... What is Docker? Dockerize a Java
Web Application in five steps Leassons learned -
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 -
What is Docker? Used Technologies Docker Libcontainer Namespaces Control Groups
Storage Backends Layered/CoW Filesystems Linux Kernel Software Defined Networking -
What is Docker? Images & Container read only writable empty
after creation many containers can be created based on one image -
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 -
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 Virtual Machine (Linux) Images Container
Mac OS X Windows /Users /Users Docker Client Docker Daemon -
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 -
Dockerize a Java Web App MySql - Container Docker Machine
docker-machine \ create \ --driver=virtualbox \ jsd2015 -
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 -
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 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 Docker Image by Foot #
Dockerfile FROM java:8 MAINTAINER Bernd Fischer "[email protected]" 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 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" ] -
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 …. 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, … -
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