Javantura v3 - Conquer the Internet of Things with Java and Docker – Johan Janssen

35
Conquer the Internet of Things with Java and Docker Johan Janssen (Info Support) @johanjanssen42

Transcript of Javantura v3 - Conquer the Internet of Things with Java and Docker – Johan Janssen

Page 1: Javantura v3 - Conquer the Internet of Things with Java and Docker – Johan Janssen

Conquer the Internet of Things with Java

and DockerJohan Janssen (Info Support) @johanjanssen42

Page 2: Javantura v3 - Conquer the Internet of Things with Java and Docker – Johan Janssen

Content

Internet of Things

Docker and Java on a Raspberry Pi

Advantages of using Docker

Questions

Page 3: Javantura v3 - Conquer the Internet of Things with Java and Docker – Johan Janssen

Internet of Things

Page 4: Javantura v3 - Conquer the Internet of Things with Java and Docker – Johan Janssen

Developments outside the IoT

Continuous Delivery Virtual machines Provisioning (Chef, Puppet, Vagrant …) Version control / infrastructure as code Isolation

Updating and synchronizing environments

Page 5: Javantura v3 - Conquer the Internet of Things with Java and Docker – Johan Janssen

What to deliver?

Page 6: Javantura v3 - Conquer the Internet of Things with Java and Docker – Johan Janssen

Docker

Page 7: Javantura v3 - Conquer the Internet of Things with Java and Docker – Johan Janssen

Software issue

Page 8: Javantura v3 - Conquer the Internet of Things with Java and Docker – Johan Janssen

Software solution

Page 9: Javantura v3 - Conquer the Internet of Things with Java and Docker – Johan Janssen

Why Docker To enable continuous delivery Quickly provision environments Easy to roll forward Security

For instance to run ‘untrusted’ applications like a Dropbox client

Alternative for virtual machines On top of virtual machines

Page 10: Javantura v3 - Conquer the Internet of Things with Java and Docker – Johan Janssen

Docker vs Virtual Machines

Page 11: Javantura v3 - Conquer the Internet of Things with Java and Docker – Johan Janssen

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

Page 12: Javantura v3 - Conquer the Internet of Things with Java and Docker – Johan Janssen

Raspberry installation Update repositories

pacman –Syy Optional update al packages:

pacman -Syu Install Docker

pacman -S docker

Page 13: Javantura v3 - Conquer the Internet of Things with Java and Docker – Johan Janssen

My first Pi Docker container Docker on the Raspberry Pi

docker run -i –tresin/rpi-raspbian /bin/bash

Page 14: Javantura v3 - Conquer the Internet of Things with Java and Docker – Johan Janssen

Tomcat DockerfileFROM resin/rpi-raspbianRUN apt-get update

RUN apt-get install -y openjdk-8-jre-headless wgetRUN wget -O /tmp/tomcat8.tar.gz http://archive.apache.org/dist/tomcat/tomcat-8/v8.0.9/bin/apache-tomcat-8.0.9.tar.gzRUN (cd /opt && tar zxf /tmp/tomcat8.tar.gz)RUN (mv /opt/apache-tomcat* /opt/tomcat)ENV JAVA_HOME /usr/lib/jvm/java-1.8.0-openjdk-armhf

RUN rm -rf /opt/tomcat/webapps/docs /opt/tomcat/webapps/examples /opt/tomcat/webapps/host-manager /opt/tomcat/webapps/manager

EXPOSE 8080CMD ["/opt/tomcat/bin/catalina.sh", "run"]

Page 15: Javantura v3 - Conquer the Internet of Things with Java and Docker – Johan Janssen

TomcatApp DockerfileFROM tomcat

ADD DockerPiExample.war /opt/tomcat/webapps/

Page 16: Javantura v3 - Conquer the Internet of Things with Java and Docker – Johan Janssen

Directory structure Main directory

Tomcat Dockerfile

TomcatApp Dockerfile DockerPiExample.war

Page 17: Javantura v3 - Conquer the Internet of Things with Java and Docker – Johan Janssen

Build Create the Dockerfiles Build the containers

cd Tomcat (optional)docker build -t tomcat . (optional)cd .. (optional)cd TomcatAppdocker build -t tomcatapp .

Page 18: Javantura v3 - Conquer the Internet of Things with Java and Docker – Johan Janssen

Run Start the container

docker run -p 8042:8080 -d tomcatapp

Page 19: Javantura v3 - Conquer the Internet of Things with Java and Docker – Johan Janssen

Demo

Page 20: Javantura v3 - Conquer the Internet of Things with Java and Docker – Johan Janssen

Docker overview

Page 21: Javantura v3 - Conquer the Internet of Things with Java and Docker – Johan Janssen

One ring to rule them all

Page 22: Javantura v3 - Conquer the Internet of Things with Java and Docker – Johan Janssen

Docker registry

Creating the Docker registrydocker run -p 5000:5000 registry

Page 23: Javantura v3 - Conquer the Internet of Things with Java and Docker – Johan Janssen

Docker client 1 (push) Change container (using touch for instance) Commit

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

New containerid -> ff7e Push

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

Page 24: Javantura v3 - Conquer the Internet of Things with Java and Docker – Johan Janssen

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

Page 25: Javantura v3 - Conquer the Internet of Things with Java and Docker – Johan Janssen

Updating containers

Page 26: Javantura v3 - Conquer the Internet of Things with Java and Docker – Johan Janssen

Pull update only on Docker client 2

docker 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 27: Javantura v3 - Conquer the Internet of Things with Java and Docker – Johan Janssen

We need lots of Docker containersGeneralBase

AppServerBase

Environment D

Environment T

Environment A

Environment P

Jenkins

JenkinsDataContainer

SonarQube Gitblit Nexus

Page 28: Javantura v3 - Conquer the Internet of Things with Java and Docker – Johan Janssen

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 29: Javantura v3 - Conquer the Internet of Things with Java and Docker – Johan Janssen

Execution time on laptop

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

Page 30: Javantura v3 - Conquer the Internet of Things with Java and Docker – Johan Janssen

Summary

Big potential market for Docker and Java

Easy to use

Highly flexible and customizable

Page 31: Javantura v3 - Conquer the Internet of Things with Java and Docker – Johan Janssen

Isolation

Page 32: Javantura v3 - Conquer the Internet of Things with Java and Docker – Johan Janssen

Isolation

Page 33: Javantura v3 - Conquer the Internet of Things with Java and Docker – Johan Janssen

Isolation

Page 34: Javantura v3 - Conquer the Internet of Things with Java and Docker – Johan Janssen

Isolation

Page 35: Javantura v3 - Conquer the Internet of Things with Java and Docker – Johan Janssen

Questions http://blogs.infosupport.com Ask!

[email protected] @johanjanssen42