sdfsd - Info Support Blog

Johan Janssen, Info Support
Internet of Things
Docker and Java on a Raspberry Pi
Jenkins
Questions
Huge and still growing
Not stable yet, lots of innovation
Cool new technologies
Suitable for Java!
Continuous Delivery
Virtual machines
Provisioning (Chef, Puppet, Vagrant …)
Version control / infrastructure as code
Isolation
Updating and synchronizing environments
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
Disk space efficiency
Memory efficiency
Speed
Compatibility (run anywhere)
Isolation
Versioning
Internet of Things (Raspberry Pi etc.)
Simple general commands
No Domain Specific Language (DSL)
Configuration with operating system commands
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 Ubuntu 14.04
apt-get install docker.io
docker.io run -i -t
ubuntu:saucy /bin/bash
Docker on the Raspberry Pi
docker run -i –t
resin/rpi-raspbian /bin/bash
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.06rpi.img of=/dev/sdX
Change partitions (optional)
Put the SD card in the Raspberry Pi and boot username
and password are both ‘root’
Update repositories
pacman –Syy
Optional update al packages:
pacman -Syu
Install Docker
pacman -S docker
Start Docker service
systemctl start docker
Auto start Docker service on boot
systemctl enable docker
Reboot
cp /etc/netctl/examples/ethernet-static
/etc/netctl/static
Edit /etc/netctl/static
Description='A basic static ethernet connection'
Interface=eth0
Connection=ethernet
AutoWired=yes
IP=static
Address=('192.168.1.3/24')
Gateway='192.168.1.1'
DNS=('192.168.1.1')
Enable static ip
netctl enable static
Disable static ip
mv /etc/netctl/static
/etc/netctl/examples/
FROM resin/rpi-raspbian
RUN apt-get update
RUN apt-get install -y openjdk-7-jre-headless wget
RUN wget -O /tmp/tomcat8.tar.gz
http://archive.apache.org/dist/tomcat/tomcat-8/v8.0.9/bin/apache-tomcat8.0.9.tar.gz
RUN (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 8080
CMD ["/opt/tomcat/bin/catalina.sh", "run"]
FROM resin/rpi-raspbian
RUN apt-get install -y openjdk-7-jre-headless
wget
ENV JAVA_HOME /usr/lib/jvm/java-1.7.0-openjdkarmhf
EXPOSE 8080
CMD ["/opt/tomcat/bin/catalina.sh", "run"]
FROM tomcat
ADD DockerPiExample.war
/opt/tomcat/webapps/
Main directory
BuildAndRunScript.sh
Tomcat
Dockerfile
TomcatExtra
Dockerfile
DockerPiExample.war
Create the Dockerfiles
Build the containers
cd Tomcat (optional)
docker build -t tomcat . (optional)
cd .. (optional)
cd TomcatExtra
docker build -t tomcatextra .
Start the container
docker run -p 8080:8080 -d tomcatextra
April Fools prank
It might become real
Start / stop / restart
docker [start/stop/restart]
Follow SystemOut and SystemErr
docker logs -f containerid
containerid
Show (running) containers
docker ps –a
Show processes running in container
docker diff containerid
Show changes in the container
docker top containerid
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)
Creating the Docker registry
docker run -p 5000:5000 registry
Change container (using touch for instance)
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
Pull
docker.io pull
192.168.56.31:5000/test-version-0.2
Run
docker.io run -i -t ff7e /bin/bash
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 complete
153bf43b408a: Download complete
docker images -tree
└─153bf43b408a 194.2 MB test-version-0.1:latest
└─ff7e110ebadd 194.2 MB test-version-0.2:latest
Commands are easier
Faster and easier migration
Requires less extra resources
Containers are the same, for instance when
using apt-get update
Not the latest security patches
GeneralBase
AppServerBase
Environment D
Environment T
Environment A
Environment P
Jenkins
Sonar
JenkinsDataContainer
Gitblit
Nexus
# 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
real 4m11.729s
user 0m3.329s
sys 0m10.054s
Simple to use
Really popular
Used in many organizations
Regular updates
Big community creating plugins etc.
Most developers already use it
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!
Big potential market for Docker and Java
Easy to use
Highly flexible and customizable
[email protected]