Using the Same Docker Container for Development and in the Cloud

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

description

Using the Same Docker Container for Development and in the Cloud. Johan Janssen, Info Support. Content. Continuous delivery Docker Jenkins Questions. Continuous Delivery. Automate everything Software quality Continuous improvement Regular deployments Anyone can deploy. - PowerPoint PPT Presentation

Transcript of Using the Same Docker Container for Development and in the Cloud

Page 1: Using the Same  Docker  Container for Development and in the Cloud

Using the Same Docker Container for Development and in

the CloudJohan Janssen, Info Support

Page 2: Using the Same  Docker  Container for Development and in the Cloud

Content

Continuous delivery

Docker

Jenkins

Questions

Page 3: Using the Same  Docker  Container for Development and in the Cloud

Continuous Delivery Automate everything

Software quality

Continuous improvement

Regular deployments

Anyone can deploy

Page 4: Using the Same  Docker  Container for Development and in the Cloud

Deployment pipeline

Version control

Compile

Quality checks

Testing

Deployments

DevOps End users

Etcetera

Setup environment

Page 5: Using the Same  Docker  Container for Development and in the Cloud

Deployment pipeline

Page 6: Using the Same  Docker  Container for Development and in the Cloud

Focus of this presentation

Automate environment provisioning

Automate application deployment

Page 7: Using the Same  Docker  Container for Development and in the Cloud

What to deliver?

Page 8: Using the Same  Docker  Container for Development and in the Cloud

Docker

Page 9: Using the Same  Docker  Container for Development and in the Cloud

Transportation issue

Page 10: Using the Same  Docker  Container for Development and in the Cloud

Transportation solution

Page 11: Using the Same  Docker  Container for Development and in the Cloud

Software issue

Page 12: Using the Same  Docker  Container for Development and in the Cloud

Software solution

Page 13: Using the Same  Docker  Container for Development and in the Cloud

Docker compatibility

Page 14: Using the Same  Docker  Container for Development and in the Cloud

Demo

Page 15: Using the Same  Docker  Container for Development and in the Cloud

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

Page 16: Using the Same  Docker  Container for Development and in the Cloud

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

Page 17: Using the Same  Docker  Container for Development and in the Cloud

Docker vs provisioning tools

Simple general commands No Domain Specific Language (DSL) Configuration with operating system

commands

Page 18: Using the Same  Docker  Container for Development and in the Cloud

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

Page 19: Using the Same  Docker  Container for Development and in the Cloud

Docker on CIO TODAY

Page 20: Using the Same  Docker  Container for Development and in the Cloud

Docker ecosystem

Page 21: Using the Same  Docker  Container for Development and in the Cloud

My first Docker container

Docker on Ubuntu 14.04

apt-get install docker.io

docker.io run -i -t ubuntu:saucy /bin/bash

Page 22: Using the Same  Docker  Container for Development and in the Cloud

Docker technology

Page 23: Using the Same  Docker  Container for Development and in the Cloud

Dockerfile GeneralBaseFROM ubuntu:saucy

RUN apt-get -y install software-properties-commonRUN add-apt-repository ppa:webupd8team/javaRUN apt-get update && apt-get -y upgradeRUN echo "oracle-java7-installer shared/accepted-oracle-license-v1-1 boolean true" | debconf-set-selectionsRUN apt-get -y install oracle-java7-installerENV JAVA_HOME /usr/lib/jvm/java-7-oracle

Page 24: Using the Same  Docker  Container for Development and in the Cloud

Dockerfile SonarFROM GeneralBase

RUN apt-get install -y wget unzipRUN wget http://dist.sonar.codehaus.org/sonarqube-4.2.zipRUN unzip sonarqube-4.2.zip -d /optRUN rm sonarqube-4.2.zip

EXPOSE 9000 EXPOSE 9092CMD ["/opt/sonarqube-4.2/bin/linux-x86-64/sonar.sh", "console", "/bin/bash"]

Page 25: Using the Same  Docker  Container for Development and in the Cloud

Directory structure Main directory

BuildAndRunScript.sh GeneralBase

Dockerfile Sonar

Dockerfile

Page 26: Using the Same  Docker  Container for Development and in the Cloud

Build Create the Dockerfiles Build the containers:

cd GeneralBase (optional)docker.io build -t GeneralBase . (opt..)cd .. (optional)cd Sonardocker.io build -t Sonar .

Page 27: Using the Same  Docker  Container for Development and in the Cloud

Run Start the container

docker.io run -p 9000:9000 –p 9092:9092 -d Sonar

Page 28: Using the Same  Docker  Container for Development and in the Cloud

List all in(active) containers# docker.io ps –aCONTAINER 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

Page 29: Using the Same  Docker  Container for Development and in the Cloud

Controlling containers

Start / stop / restartdocker [start/stop/restart] containerid

Follow SystemOut and SystemErrdocker logs -f containerid

Page 30: Using the Same  Docker  Container for Development and in the Cloud

Controlling containers Show (running) containers

docker ps –a

Show processes running in containerdocker diff containerid

Show changes in the containerdocker top containerid

Page 31: Using the Same  Docker  Container for Development and in the Cloud

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)

Page 32: Using the Same  Docker  Container for Development and in the Cloud

We need lots of Docker containers

GeneralBase

AppServerBase

Environment D

Environment T

Environment A

Environment P

Jenkins

JenkinsDataContainer

Sonar Gitblit Nexus

Page 33: Using the Same  Docker  Container for Development and in the Cloud

Data volumes Dockerfile

ENV JENKINS_HOME /var/JenkinsData

Docker commandsdocker.io run -v /var/JenkinsData –name JenkinsDataContainer ubuntu:saucy true

docker.io run -p 8080:8080 --volumes-from JenkinsDataContainer -d Jenkins

Page 34: Using the Same  Docker  Container for Development and in the Cloud

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

Page 35: Using the Same  Docker  Container for Development and in the Cloud

Execution time

real 4m11.729suser 0m3.329s sys 0m10.054s

Page 36: Using the Same  Docker  Container for Development and in the Cloud

Moving

Page 37: Using the Same  Docker  Container for Development and in the Cloud

Export / import container

Exportsudo docker.io export

fc8696f5b8b4 > jenkins-backup.tar

Importsudo cat jenkins-backup.tar |

sudo docker.io import – jenkins

Page 38: Using the Same  Docker  Container for Development and in the Cloud

Backup data containersudo docker.io run -rm

--volumes-from JenkinsDataContainer

-v $(pwd):/backup busybox tar cvf backup.tar

/var/JenkinsData    

Page 39: Using the Same  Docker  Container for Development and in the Cloud

Restore data containersudo docker.io run -v /var/JenkinsData

--name JenkinsDataContainer ubuntu:saucy true

sudo docker.io run -rm --volumes-from

JenkinsDataContainer -v $(pwd):/backup busybox tar xvf /backup/backup.tar –C / 

 

Page 40: Using the Same  Docker  Container for Development and in the Cloud

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

Page 41: Using the Same  Docker  Container for Development and in the Cloud

Docker overview

Page 42: Using the Same  Docker  Container for Development and in the Cloud

One ring to rule them all

Page 43: Using the Same  Docker  Container for Development and in the Cloud

Docker registry

Creating the Docker registrydocker run -p 5000:5000 registry

Page 44: Using the Same  Docker  Container for Development and in the Cloud

Docker client 1 (push) Modify container (for instance with touch) Commit

docker.io commit 064f192.168.56.31:5000/test-version-0.2

New containerid -> ff7e

Pushdocker.io push

192.168.56.31:5000/test-version-0.2

Page 45: Using the Same  Docker  Container for Development and in the Cloud

Docker client 2 (pull) Pull

docker.io pull 192.168.56.31:5000/test-version-0.2

Rundocker.io run -i -t ff7e /bin/bash

View the changed container

Page 46: Using the Same  Docker  Container for Development and in the Cloud

Updating containers

Page 47: Using the Same  Docker  Container for Development and in the Cloud

Pull update onlydocker images -tree└─153bf43b408a 194.2 MB test-version-0.1:latest

docker pull 192.168.56.31:5000/test-version-0.2 ff7e110ebadd: Download complete153bf43b408a: Download complete

docker images -tree└─153bf43b408a 194.2 MB test-version-0.1:latest └─ff7e110ebadd 194.2 MB test-version-0.2:latest

Page 48: Using the Same  Docker  Container for Development and in the Cloud

Use registry instead exports

Commands are easier

Faster and easier migration

Page 49: Using the Same  Docker  Container for Development and in the Cloud

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

Page 50: Using the Same  Docker  Container for Development and in the Cloud

Docker vs Virtual Machines

Page 51: Using the Same  Docker  Container for Development and in the Cloud

Jenkins

Page 52: Using the Same  Docker  Container for Development and in the Cloud

Demo

Page 53: Using the Same  Docker  Container for Development and in the Cloud

Why Jenkins Simple to use Really popular

Used in many organizations Regular updates Big community creating plugins etc.

Most developers already use it

Page 54: Using the Same  Docker  Container for Development and in the Cloud

Jenkins

Page 55: Using the Same  Docker  Container for Development and in the Cloud

Backend pipeline

Page 56: Using the Same  Docker  Container for Development and in the Cloud

Frontend pipeline

Page 57: Using the Same  Docker  Container for Development and in the Cloud

Combined pipeline

Page 58: Using the Same  Docker  Container for Development and in the Cloud

Automatic versus manual deployment

Continuous delivery

Continuous deployment

Page 59: Using the Same  Docker  Container for Development and in the Cloud

Automatic versus manual

Page 60: Using the Same  Docker  Container for Development and in the Cloud

Build pipeline plugin

Page 61: Using the Same  Docker  Container for Development and in the Cloud

Example build pipeline

TAP

D

1

2

34

7

8

9

10

56?

6?

Page 62: Using the Same  Docker  Container for Development and in the Cloud

Publish over SSH plugin

Page 63: Using the Same  Docker  Container for Development and in the Cloud

Publish over SSH plugin

Page 64: Using the Same  Docker  Container for Development and in the Cloud

Join Plugin Execute job after several (parallel) jobs are finished.

FirstJob

ParallelJob1

ParallelJob2

LastJob

Page 65: Using the Same  Docker  Container for Development and in the Cloud

Using the Join Plugin

Page 66: Using the Same  Docker  Container for Development and in the Cloud

Build Pipeline Plugin & Join Plugin combined

Page 67: Using the Same  Docker  Container for Development and in the Cloud

I need more! Good looking join Complex workflow Etcetera

Advantage: Jenkins jobs are the basis and can be reused. Try to keep it simple!

Page 68: Using the Same  Docker  Container for Development and in the Cloud

Alternatives for Build Pipeline Plugin

Build Flow Plugin Domain Specific Language Features like retry, parallel,

guard/rescue (similar to try/finally)

Multijob Plugin Delivery Pipeline Plugin

Page 69: Using the Same  Docker  Container for Development and in the Cloud

Keep it simple“Life is really simple, but we insist on making it complicated.”

- Confucius

Page 70: Using the Same  Docker  Container for Development and in the Cloud

Build pipeline demo

Page 71: Using the Same  Docker  Container for Development and in the Cloud

Tips Use a (private) Docker registry Use images from the registry instead of export Keep environmental settings separate Use Jenkins to manage everything Do not add extra functionality like OpenSSH Think about topics such as security, monitoring and logging Separate concerns in separate containers Inherit containers

Page 72: Using the Same  Docker  Container for Development and in the Cloud

Summary

Big potential market for Docker and Java

Easy to use

Highly flexible and customizable

Page 73: Using the Same  Docker  Container for Development and in the Cloud

Isolation

Page 74: Using the Same  Docker  Container for Development and in the Cloud

Isolation

Page 75: Using the Same  Docker  Container for Development and in the Cloud

Isolation

Page 76: Using the Same  Docker  Container for Development and in the Cloud

Isolation

Page 77: Using the Same  Docker  Container for Development and in the Cloud

Summary

Page 78: Using the Same  Docker  Container for Development and in the Cloud

Questions

[email protected]