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

Docker in Software Development - Current State

Docker in Software Development - Current State

0e2ebc602688ac211ed75cd9d84caffd?s=128

berndfischer63

September 02, 2016
Tweet

Transcript

  1. Docker@Dev Current State Docker@Bamberg - Meetup 01.09.2016 Bernd Fischer

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

    Cloud, ...) Docker enthusiast Agile and Devops infected berndfischer63@gmail.com @berndfischer63 JUG Saxony e.V., Docker Meetup Dresden CTO/Consultant/Developer MindApproach GmbH, Dresden bfischer@mindapproach.de
  3. Agenda Docker@Dev-Current State Prerequisits ◦ Basic knowledge about Docker etc.

  4. 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)
  5. Agenda Docker@Dev-Current State Paradigms Demo Application (Topics) Topics

  6. Paradigms

  7. Paradigms You build it you run it Werner Vogels, CTO

    Amazon, 2006 [Gra01]
  8. Paradigms DevOps Andrew Clay Shafer, Patrick Debois, Agile Conference 2008

    DevOpsDays Ghent 2009
  9. Paradigms Automate almost everything Continuous Delivery, 2010 [HuFa01]

  10. Paradigms Immutable Infrastructure as Code Martin Fowler [Fow01], [Fow02], [Fow03]

  11. Paradigms Same Environment on all Stages by myself

  12. Paradigms Traceability by myself

  13. Demo Application

  14. 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
  15. Demo App DEMO

  16. Demo App MySql Installation needed …

  17. Demo App MySql - Local Installation Folder: ~/Server

  18. Demo App MySql - Local Installation

  19. Demo App MySql - Local Installation Not nice …

  20. Demo App MySql - ???

  21. Demo App MySql - Docker Container

  22. Topic Dev Environment Local • Mac Book - OS X

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

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

    OS X Windows /Users /Users Docker Client Docker Daemon
  25. Topic Dev Environment Local Docker Machine docker-machine \ create \

    --driver=virtualbox \ dev01
  26. 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
  27. Topic Dev Environment Local How to access Container from developer

    host (notebook)?
  28. 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)
  29. 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>
  30. Demo App MySql - Container DEMO

  31. 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 root@192.168.99.100 -p 10022 # another tab nc localhost 11122
  32. Demo App Docker Image - Manual # Dockerfile FROM frolvlad/alpine-oraclejdk8:cleaned

    MAINTAINER Bernd Fischer "berndfischer63@gmail.com” ENV MODIFIED_AT 2016-04-06_1230 VOLUME /tmp WORKDIR /opt/ ADD @project.build.finalName@.jar /opt/@project.artifactId@ ENTRYPOINT [ "java", "-jar", "-Djava.security.egd=file:/dev/./urandom", "@project.artifactId@" ]
  33. Demo App Docker Image - Manual docker build ... docker

    tag ... docker push ...
  34. 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> ...
  35. Demo App Docker Image by Maven DEMO

  36. 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: ...
  37. 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: ...
  38. Demo App Docker Push (Registry) docker tag ... docker login

    ... docker push ...
  39. Demo App Docker Push (Registry)

  40. Demo App Docker Push (Registry)

  41. Demo App Docker Push (Registry)

  42. 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}" ... }
  43. Further Topics

  44. Topic Change Speed • down/backward compatibility ?

  45. 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, ...
  46. Topic Architecture mismatch between “classical” application design and “running” containers

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

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

    OS X Windows /Users /Users Docker Client Docker Daemon
  49. 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
  50. 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
  51. 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?)
  52. 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)
  53. Topic Docker Images Life Cycle Creating … ◦ Dockerfile ▪

    syntax …. ▪ layering rules … ▪ defining and handling of dependencies between images ??? ◦ docker commit ??? ▪ via Ansible, Packer or others?
  54. 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 ...
  55. 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 (?)
  56. 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
  57. 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 …???
  58. Lessons learned

  59. Lessons Learned Docker rocks!

  60. Lessons Learned Development Tools/Compoments Build-Systems, Compiler, Databases, ... Packaging and

    Deploying similar “enviroments” over all stages (dev, tst, prd)
  61. Lessons Learned Dev-Environment-Integration … Docker Images Life Cycle

  62. Questions … ?

  63. Thanks for attention ...

  64. 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/ •
  65. 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