1 / 78

Using Docker for Development and Cloud Deployment

Learn how to use the same Docker container for development and in the cloud, automate environment provisioning and application deployment, and improve software quality with Docker.

Download Presentation

Using Docker for Development and Cloud Deployment

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Using the Same Docker Container for Development and in the Cloud Johan Janssen, Info Support

  2. Content • Continuous delivery • Docker • Jenkins • Questions

  3. Continuous Delivery • Automate everything • Software quality • Continuous improvement • Regular deployments • Anyone can deploy

  4. Deployment pipeline Setup environment Quality checks Version control Compile Testing Deployments Etcetera DevOps End users

  5. Deployment pipeline

  6. Focus of this presentation • Automate environment provisioning • Automate application deployment

  7. What to deliver?

  8. Docker

  9. Transportation issue

  10. Transportation solution

  11. Software issue

  12. Software solution

  13. Docker compatibility

  14. Demo

  15. Why Docker • To enable continuous delivery • Quickly provision environments • Run the same software local and in the cloud • Easy to move software • Better performance • Higher availability • Cheaper

  16. Docker vs Virtual Machines • Disk space efficiency • Memory efficiency • Speed • Compatibility (run anywhere) • Isolation • Versioning • Internet of Things (Raspberry Pi etc.)

  17. Docker vs provisioning tools • Simple general commands • No Domain Specific Language (DSL) • Configuration with operating system commands

  18. Docker activity • Since March 2013 • 8741 commits in 15 months • More than 460 570 contributors • Downloaded 2.75 13 million times • More than 14000 30000 Dockerized apps • >6500 Docker related projects on GitHub • More than 90 user groups • DockerCon (Europe) • Support from Google, VMWare, RackSpace, Red Hat, IBM, Microsoft etcetera

  19. Docker on CIO TODAY

  20. Docker ecosystem

  21. My first Docker container • Docker on Ubuntu 14.04 apt-get install docker.io docker.io run -i -t ubuntu:saucy /bin/bash

  22. Docker technology

  23. DockerfileGeneralBase FROM ubuntu:saucy RUN apt-get -y install software-properties-common RUN add-apt-repository ppa:webupd8team/java RUN apt-get update && apt-get -y upgrade RUN echo "oracle-java7-installer shared/accepted-oracle-license-v1-1 boolean true" | debconf-set-selections RUN apt-get -y install oracle-java7-installer ENV JAVA_HOME /usr/lib/jvm/java-7-oracle

  24. Dockerfile Sonar FROM GeneralBase RUN apt-get install -y wgetunzip RUN wget http://dist.sonar.codehaus.org/sonarqube-4.2.zip RUN unzip sonarqube-4.2.zip -d /opt RUN rm sonarqube-4.2.zip EXPOSE 9000 EXPOSE 9092 CMD ["/opt/sonarqube-4.2/bin/linux-x86-64/sonar.sh", "console", "/bin/bash"]

  25. Directory structure • Main directory • BuildAndRunScript.sh • GeneralBase • Dockerfile • Sonar • Dockerfile

  26. Build • Create the Dockerfiles • Build the containers: cd GeneralBase(optional) docker.io build -t GeneralBase. (opt..) cd .. (optional) cd Sonar docker.io build -t Sonar .

  27. Run • Start the container docker.io run -p 9000:9000 –p 9092:9092 -d Sonar

  28. List all in(active) containers # docker.io ps–a CONTAINER ID: ecbecf77461b CREATED: 32 minutes ago STATUS: Up 32 minutes PORTS: 0.0.0.0:9000->9000/tcp, 0.0.0.0:9092->9092/tcp

  29. Controlling containers • Start / stop / restart docker [start/stop/restart] containerid • Follow SystemOut and SystemErr docker logs -f containerid

  30. Controlling containers • Show (running) containers dockerps –a • Show processes running in container dockerdiff containerid • Show changes in the container dockertop containerid

  31. Controlling containers • Stop all containers docker.io stop $(docker.io ps -a -q) • Remove all containers docker.io rm $(docker.io ps -a -q) • Remove all images docker.io rmi $(docker.io images -q)

  32. We need lots of Docker containers

  33. Data volumes • Dockerfile ENV JENKINS_HOME /var/JenkinsData • Docker commands docker.io run -v /var/JenkinsData–name JenkinsDataContainerubuntu:saucy true docker.io run -p 8080:8080 --volumes-from JenkinsDataContainer -d Jenkins

  34. Diskspace # docker.io images --tree └─ 179.9 MB Tags: ubuntu:saucy └─253.6 MB └─741.8 MB Tags: GeneralBase:latest └─763.6 MB Tags: AppServerBase:latest ├─763.6 MB Tags: EnvironmentP:latest └─865.6 MB Tags: Nexus:latest └─808.3 MB Tags: Gitblit:latest └─901.5 MB Tags: Sonar:latest └─805.4 MB Tags: Jenkins:latest

  35. Execution time real 4m11.729s user 0m3.329s sys 0m10.054s

  36. Moving

  37. Export / import container • Export sudodocker.io export fc8696f5b8b4 > jenkins-backup.tar • Import sudocat jenkins-backup.tar | sudodocker.io import – jenkins

  38. Backup data container sudodocker.io run -rm --volumes-from JenkinsDataContainer -v $(pwd):/backup busybox tar cvf backup.tar /var/JenkinsData

  39. Restore data container sudodocker.io run -v /var/JenkinsData --name JenkinsDataContainer ubuntu:saucytrue sudo docker.io run -rm --volumes-from JenkinsDataContainer -v $(pwd):/backup busybox tar xvf /backup/backup.tar –C /   

  40. Run restored containers • Run container sudo docker.io run -e JENKINS_HOME=/var/JenkinsData -p 80:8080 --name Jenkins --volumes-from JenkinsDataContainer -d 1478be52bb java -jar /usr/local/bin/jenkins.war

  41. Docker overview

  42. One ring to rule them all

  43. Docker registry • Creating the Docker registry docker run -p 5000:5000 registry

  44. Docker client 1 (push) • Modify container (for instance with touch) • Commit docker.io commit 064f 192.168.56.31:5000/test-version-0.2 • New containerid -> ff7e • Push docker.io push 192.168.56.31:5000/test-version-0.2

  45. Docker client 2 (pull) • Pull docker.io pull 192.168.56.31:5000/test-version-0.2 • Run docker.io run -i -t ff7e /bin/bash • View the changed container

  46. Updating containers

  47. Pull update only dockerimages -tree └─153bf43b408a 194.2 MB test-version-0.1:latest dockerpull 192.168.56.31:5000/test-version-0.2 ff7e110ebadd: Download complete 153bf43b408a: Download complete dockerimages -tree └─153bf43b408a 194.2 MB test-version-0.1:latest └─ff7e110ebadd 194.2 MB test-version-0.2:latest

  48. Use registry instead exports • Commands are easier • Faster and easier migration

  49. Use registry instead of multiple builds • Requires less extra resources • Containers are the same, for instance when using apt-get update • Not the latest security patches

  50. Docker vs Virtual Machines

More Related