Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Docker in Software Development - Current State

Docker in Software Development - Current State

berndfischer63

September 02, 2016
Tweet

More Decks by berndfischer63

Other Decks in Programming

Transcript

  1. Who’s that guy? Passionate Java Developer (especially Spring Framework, Boot,

    Cloud, ...) Docker enthusiast Agile and Devops infected [email protected] @berndfischer63 JUG Saxony e.V., Docker Meetup Dresden CTO/Consultant/Developer MindApproach GmbH, Dresden [email protected]
  2. Agenda Docker@Dev-Current State Subjective views / personal opinions Using Docker

    in Software Development ◦ Complete life cycle (SDLC) ◦ Daily (development) activities ◦ Java, Backend, Web, ... Current State ◦ Review ◦ Reached Goals ◦ Hotspots, Alternatives (topics for today)
  3. Demo App 10000 Feet View Linux (Ubuntu 16.04.0-LTS / Alpine

    / ...) java -jar ... url username password JVM Application Spring Boot embedded Tomcat Database MySql
  4. Topic Dev Environment Local • Mac Book - OS X

    10.11 • Docker needs (L)unix (or Windows …)
  5. Topic Dev Environment Local • Mac Book - OS X

    10.11 • Docker needs (L)unix (or Windows …) • and now
  6. Topic Dev Environment Local Virtual Machine (Linux) Images Container Mac

    OS X Windows /Users /Users Docker Client Docker Daemon
  7. Demo App MySql - Container Docker Compose # docker-compose-01.yaml (snippet)

    mysql: image: mysql:5.7.14 environment: - MYSQL_ROOT_PASSWORD=9876 - MYSQL_USER=test - MYSQL_PASSWORD=1234 - MYSQL_DATABASE=test volumes: - mysql_data:/var/lib/mysql
  8. Topic Dev Environment Local How to access Container from developer

    host (notebook)? Mac OS X: sudo route -n add 172.??.0.0/16 192.168.99.100 How to test? ping $(docker-printContainerIP tst_mysql_1)
  9. Topic Dev Environment Local How to access developer host (notebook)

    from container? Mac OS X: sudo route -n add 172.??.0.0/16 192.168.99.100 How to test? ip addr show en0 # get notebook ip docker exec -it tst_mysql_1 bash ping <notebook-ip>
  10. Topic Dev Environment Remote How to access Container from developer

    host (notebook)? docker run -d --name=sshd --net=tst_back -p 10022:22 rastasheep/ubuntu-sshd:14.04 ssh -o UserKnownHostsFile=/dev/null -L 11122:tst_mysql_1:3306 [email protected] -p 10022 # another tab nc localhost 11122
  11. Demo App Docker Image - Manual # Dockerfile FROM frolvlad/alpine-oraclejdk8:cleaned

    MAINTAINER Bernd Fischer "[email protected]” ENV MODIFIED_AT 2016-04-06_1230 VOLUME /tmp WORKDIR /opt/ ADD @[email protected] /opt/@project.artifactId@ ENTRYPOINT [ "java", "-jar", "-Djava.security.egd=file:/dev/./urandom", "@project.artifactId@" ]
  12. Demo App Docker Image by Maven # Maven (snippet) <profile>

    <id>buildDockerImage</id> <build> <plugins> ... <plugin> <groupId>com.spotify</groupId> <artifactId>docker-maven-plugin</artifactId> <version>0.3.5</version> <configuration> <imageName>mapp/ma-demo-helloworld-web</imageName> <imageTags> <imageTag>${project.version}</imageTag> </imageTags> ...
  13. Demo App Compostion # docker-compose-02.yaml (snippet) app: image: befi/demo-helloworld-web:latest networks:

    - back ports: - "8080:8080" environment: - MYSQL_HOSTNAME=mysql depends_on: - mysql mysql: ...
  14. Demo App Final Compostion # docker-compose-03.yaml (snippet) nginx: image: nginx:1.11.1

    ports: - "80:80" networks: - front app: image: befi/demo-helloworld-web:latest networks: - front - back ... mysql: ...
  15. Demo App Jenkins Pipeline // Jenkinsfile stage name: 'QS Gate

    1 - Build and Test Web Application', concurrency: 1 node { git url: 'https://gitlab.com/ma-demo/demo-helloworld-web.git' def mvnHome = tool 'M3.3.9' sh "${mvnHome}/bin/mvn clean package -DskipTests=true" } stage name: 'QS Gate 2 - Build DockerImage', concurrency: 1 node { ... sh "${mvnHome}/bin/mvn resources:copy-resources docker:build \ -PbuildDockerImage" sh "${mvnHome}/bin/mvn docker:tag -PtagDockerImage \ -DdockerRegistry=${env.DOCKER_REGISTRY}" ... }
  16. Topic Architecture mismatch between several “framework ecosystems” drying to solve

    same task differentely i.e. task: App-Distribution / Cloud • infrastrcuture level ◦ Docker … • application level ◦ Application Server i.e. JBoss, IBM Websphere, Oracle Weblogic, ...
  17. Topic Architecture mismatch between “classical” application design and “running” containers

    ◦ Init Systems ◦ Start Order ◦ Patching Systems/Applications … ◦ Containers aren’t VM’s ◦ Backup / Recovery ◦ ...
  18. Topic Dev Environment Local Docker runs not natively on Win

    (?) or OS X … Usually we need a Linux VM ...
  19. Topic Dev Environment Local Virtual Machine (Linux) Images Container Mac

    OS X Windows /Users /Users Docker Client Docker Daemon
  20. Topic Dev Environment Local Create Docker host Paradigm: Same environment

    every where ◦ Docker Toolbox / Docker for Mac / Windows ▪ only one “host/vm” …??? ◦ Docker Machine ▪ ready to use, remote providers ▪ no control about host config ◦ Vagrant (+ CM like Ansible) ▪ not so simple but highly customizable ▪ more expensive work
  21. Topic Environment Global Paradigm: Same environment everywhere ◦ Docker Host

    ◦ Boot2Docker for local dev ◦ ??? on Digital Ocean ◦ ??? on AWS ◦ CoreOS on ??? ◦ control which software runs on which “place” ◦ Packer + Vagrant + Ansible
  22. Topic Dev Environment Local Shared Folder ◦ Virtualization Provider and

    their file systems ▪ Virtualbox ▪ Parallels ▪ Xhyve (Mac), Hyper-V (Win) ◦ NFS ??? ◦ ??? ◦ sync files and their changes between host and vm ◦ permission differences between host and vm (Win?)
  23. Topic Docker Images Life Cycle Naming ◦ is terrible …

    ◦ Fqn contains registry url - but this is a “storage place”, nothing more ◦ “latest” ??? !!! ◦ no real common style (compared i.e. with Artifact naming defined by Maven)
  24. Topic Docker Images Life Cycle Creating … ◦ Dockerfile ▪

    syntax …. ▪ layering rules … ▪ defining and handling of dependencies between images ??? ◦ docker commit ??? ▪ via Ansible, Packer or others?
  25. Topic Stateful Services … Part1 ◦ life cycle difference between

    “container” and “persistent data” ◦ some applications has special needs ... ◦ some applications provide own “solution” ▪ sometimes good ones like using S3, but sometimes not ...
  26. Topic Stateful Services … Part2 ◦ “Data Container” ◦ “Host

    Volume” ▪ one host ▪ “Data Replication (rsync, Bittorrent, …) ▪ Network Filesystems (NFS, GlusterFS, ◦ “Container Runtime Storage” ◦ “Storage Drivers” ▪ Flocker (ClusterHQ) ▪ Rex-Ray ▪ Convoy (?)
  27. Topic Application Configuration ◦ Manual via Environment Variables ▪ Docker-Compose-File

    or similar config ... ▪ consider > 1 stages ◦ Config files in Host folder ▪ may be prepared and distributed via Config Managament like Ansible ◦ Config Server ▪ Spring Cloud / Config
  28. Topic Distribution of Secrets Private keys, passwords, … ◦ Environment

    variables like in my example? ▪ not a good idea ... ◦ Volumes based on Host Folders ? ▪ a little bit better, but not so flexible ◦ Secret Stores ▪ Keywhiz ▪ Hashicorp Vault ◦ Mutual Authentication necessary …???
  29. Lessons Learned Development Tools/Compoments Build-Systems, Compiler, Databases, ... Packaging and

    Deploying similar “enviroments” over all stages (dev, tst, prd)
  30. 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 • [Fow01]: Infrastructure As Code - http://www.martinfowler.com/bliki/InfrastructureAsCode.html • [Fow02]: Immutable Server - http://www.martinfowler.com/bliki/ImmutableServer.html • [Fow03]: Phoenix Server - http://www.martinfowler.com/bliki/PhoenixServer.html • • [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/ •
  31. Links ... • [RHu01] Docker-Maven-Plugin https://github.com/rhuss/docker-maven-plugin • [RHus02] Docker Maven

    Plugin Shootout: https://github.com/rhuss/shootout-docker-maven • [Spo01] Docker-Maven-Plugin https://github.com/spotify/docker-maven-plugin • • [Bro01] http://dw.connect.sys-con.com/session/2838/Aaron_Brongersma.pdf • [ZZug01] https://zwischenzugs.wordpress.com/2016/07/08/a-checklist-for-docker-in-the-enterprise/ • • [Ma01] https://gitlab.com/ma-demo/demo-helloworld-web • EOL