Johan Janssen, Info Support. Internet of Things Docker and Java on a Raspberry Pi Jenkins Questions.
Post on 21-Dec-2015
218 Views
Preview:
Transcript
Run Java applications with Docker on
the Raspberry Pi and other platforms
Johan Janssen, Info Support
Content
Internet of Things
Docker and Java on a Raspberry Pi
Jenkins
Questions
Internet of Things
Potential market
Huge and still growing
Not stable yet, lots of innovation
Cool new technologies
Suitable for Java!
Weather station
Drone
Wave Glider
Wearables
Robots
Raspberry Pi
Raspberry Pi
Developments outside the IoT
Continuous Delivery Virtual machines Provisioning (Chef, Puppet, Vagrant …) Version control / infrastructure as code Isolation
Updating and synchronizing environments
IoT limitations
What to deliver?
Docker
Transportation issue
Transportation solution
Software issue
Software solution
Docker compatibility
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
Docker vs Virtual Machines Disk space efficiency Memory efficiency Speed Compatibility (run anywhere) Isolation Versioning Internet of Things (Raspberry Pi etc.)
Docker vs provisioning tools
Simple general commands No Domain Specific Language (DSL) Configuration with operating system
commands
Docker activity Since March 2013 More than 460 570 contributors Downloaded 2.75 13 million times More than 14000 30000 Dockerized apps More than 90 user groups, DockerCon
(Europe) Support from Google, VMWare,
RackSpace, Red Hat, IBM, Microsoft etcetera
Docker on CIO TODAY
Docker ecosystem
My first Docker container
Docker on Ubuntu 14.04
apt-get install docker.io
docker.io run -i -t ubuntu:saucy /bin/bash
My first Pi Docker container
Docker on the Raspberry Pi
docker run -i –tresin/rpi-raspbian
/bin/bash
Docker technology
Raspberry installation Download Arch Linux http://downloads.raspberrypi.org/arch_latest unzip ArchLinuxARM-2014.06-rpi.img.zip Find SD card: sudo fdisk -l sudo dd bs=1M if=ArchLinuxARM-2014.06-rpi.img of=/dev/sdX Change partitions (optional) Put the SD card in the Raspberry Pi and boot username and password are both ‘root’
Raspberry installation Update repositoriespacman –Syy
Optional update al packages: pacman -Syu
Install Dockerpacman -S docker
Raspberry installation Start Docker servicesystemctl start docker
Auto start Docker service on bootsystemctl enable docker
Reboot
Configure static IP address cp /etc/netctl/examples/ethernet-static /etc/netctl/static Edit /etc/netctl/static
Description='A basic static ethernet connection'Interface=eth0Connection=ethernetAutoWired=yesIP=staticAddress=('192.168.1.3/24')Gateway='192.168.1.1'DNS=('192.168.1.1')
Static IP address Enable static ip
netctl enable static
Disable static ip mv /etc/netctl/static /etc/netctl/examples/
Tomcat DockerfileFROM resin/rpi-raspbianRUN apt-get update
RUN apt-get install -y openjdk-7-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.7.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"]
Tomcat Dockerfile explainedFROM resin/rpi-raspbian
RUN apt-get install -y openjdk-7-jre-headless wget
ENV JAVA_HOME /usr/lib/jvm/java-1.7.0-openjdk-armhf
EXPOSE 8080CMD ["/opt/tomcat/bin/catalina.sh", "run"]
TomcatExtra DockerfileFROM tomcat
ADD DockerPiExample.war /opt/tomcat/webapps/
Directory structure Main directory
BuildAndRunScript.sh Tomcat
Dockerfile TomcatExtra
Dockerfile DockerPiExample.war
Build Create the Dockerfiles Build the containers
cd Tomcat (optional)docker build -t tomcat . (optional)cd .. (optional)cd TomcatExtradocker build -t tomcatextra .
Run Start the container
docker run -p 8080:8080 -d tomcatextra
Hyper Text Coffee Pot Control Protocol
April Fools prank
It might become real
Hyper Text Coffee Pot Control Protocol
Controlling containers
Start / stop / restartdocker [start/stop/restart] containerid
Follow SystemOut and SystemErrdocker logs -f containerid
Controlling containers Show (running) containers
docker ps –a
Show processes running in containerdocker diff containerid
Show changes in the containerdocker top containerid
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)
Demo
Docker overview
One ring to rule them all
Docker registry
Creating the Docker registrydocker run -p 5000:5000 registry
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
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
Updating containers
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
Use registry instead exports
Commands are easier
Faster and easier migration
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
Docker vs Virtual Machines
We need lots of Docker containers
GeneralBase
AppServerBase
Environment D
Environment T
Environment A
Environment P
Jenkins
JenkinsDataContainer
Sonar Gitblit Nexus
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
Execution time on laptop
real 4m11.729suser 0m3.329s sys 0m10.054s
Jenkins
Why Jenkins Simple to use Really popular
Used in many organizations Regular updates Big community creating plugins etc.
Most developers already use it
Jenkins demo
Tips
Deploy the first container when the hardware is nearby this saves network traffic Use a (private) Docker registry Keep environmental settings separate
Start playing with Docker!
Summary
Big potential market for Docker and Java
Easy to use
Highly flexible and customizable
Isolation
Isolation
Isolation
Isolation
Questions
johan.janssen@infosupport.com
top related