Johan Janssen, Info Support, @johanjanssen42
Docker
Application and CD pipeline in Docker
Development in Docker
Questions

To enable continuous delivery
Quickly provision environments
Run the same software local and in the
cloud
Disk space efficiency
Memory efficiency
Speed
Compatibility (run anywhere)
Isolation
Versioning
Internet of Things (Raspberry Pi etc.)
docker run -i -t ubuntu:yakkety /bin/bash
DTAP environment
Build environment
Mainly running non-GUI applications
Continuous delivery, testing etc.
Development !

DevOps End users
Continuous delivery
Continuous deployment
1
2
3
4
6
7
8
9
5
Main directory
BuildAndRunScript.sh
GeneralBase
Dockerfile
SonarQube
Dockerfile
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
Create the Dockerfile
Build the containers:
<optional>cd GeneralBase
docker.io build -t GeneralBase .
cd .. </optional>
FROM GeneralBase
RUN apt-get install -y wget unzip
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"]
Create the Dockerfile
Build the containers:
cd SonarQube
docker.io build -t SonarQube .
Start the container
docker.io run -p 9000:9000
–p 9092:9092 -d SonarQube
# 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
Start / stop / restart
docker [start/stop/restart]
containerid
Follow SystemOut and SystemErr
docker logs -f containerid
GeneralBase
AppServerBase
Environment D
Environment T
Environment A
Environment P
Jenkins
JenkinsDataContainer
Sonar Gitblit Nexus
In the same container as the application
In a data container / data volume
On the host
Dockerfile
ENV JENKINS_HOME /var/JenkinsData
Docker commands
docker.io run -v /var/JenkinsData –name
JenkinsDataContainer ubuntu:saucy true
docker.io run -p 8080:8080 --volumes-from
JenkinsDataContainer -d Jenkins
# 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
Creating the Docker registry
docker run -p 5000:5000 registry
Modify container
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
└─153b 194.2 MB test-version-0.1:latest
docker pull 192.168.56.31:5000/test-
version-0.2
ff7e: Download complete
153b: Download complete
docker images -tree
└─153b 194.2 MB test-version-0.1:latest
└─ff7e 194.2 MB test-version-0.2:latest
Kubernetes
Docker Swarm
Mesos
…
Scalability
Failover
Rollouts and rollbacks
Self healing
Service discovery
Load balancing
…
Simple to use
Really popular
Used in many organizations
Regular updates
Big community creating plugins etc.
Most developers already use it
1
2
3
4
6
7
8
9
5
pipeline {
agent any
tools {
maven 'Maven 3.3.9'
jdk 'jdk8'
}
stages {
stage ('Build') {
steps {
sh 'mvn clean install'
}
Source: https://jenkins.io/blog/2016/12/19/declarative-pipeline-beta/
“Life is really simple, but we insist on making it
complicated.”
- Confucius

FROM java:8-jdk
RUN wget …/netbeans-8.0.2-linux.sh
RUN chmod +x netbeans*.sh
RUN sh netbeans*.sh --silent
CMD /usr/local/netbeans-8.0.2/bin/netbeans
Docker run command:
-v $PWD/workspace:/workspace
Workspace
Plugins
Application in application server
Maven repo
Configuration
Entire home folder??

No protocol specified error ->
xhost local:root
RUN wget …/netbeans-8.0.2-linux.sh
RUN chmod +x netbeans*.sh
RUN sh netbeans*.sh –silent
// Set netbeans_default_userdir=/workspace/userdir
RUN sed -i …
// Set netbeans_default_cachedir=/workspace/cachedir
RUN sed -i …
FROM java:8-jdk
// General part
CMD /usr/local/netbeans-8.0.2/bin/netbeans
docker build -t netbeansx11 .
docker run -ti --rm 
-e DISPLAY=$DISPLAY 
-v /tmp/.X11-unix:/tmp/.X11-unix 
-v $PWD/workspace:/workspace 
-v $PWD/m2:/root/.m2 
-p 8081:8080 
netbeansx11

FROM java:8-jdk
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update
RUN apt-get install -y xfce4 xvfb x11vnc supervisor
RUN adduser --disabled-password --gecos '' johan
ADD vnc.conf /etc/supervisor/conf.d/
// General part
EXPOSE 5900
CMD ["supervisord", "-n"]
[program:xvfb]
[program:x11vnc]
command=/usr/bin/x11vnc -forever -display :1
process_name = x11vnc
autorestart=true
user=johan
[program:xfce4]
command=/usr/bin/xfce4-session
process_name = xfce4
autorestart=true
user=johan
environment=DISPLAY=":1",HOME="/home/johan"
docker build -t netbeansvnc .
docker run -d 
-v $PWD/workspace:/workspace 
-v $PWD/m2:/root/.m2 
-p 5900:5900 
-p 8082:8080 
netbeansvnc

FROM fedora:22
RUN dnf -y groupinstall 'Xfce Desktop' && yum clean
all
COPY Xclients /etc/skel/.Xclients
RUN dnf -y install supervisor xrdp && dnf clean all
RUN useradd johan && echo johan:secret | chpasswd
COPY xrdp.ini /etc/supervisord.d/
# Allow all users to connect
RUN sed -i '/TerminalServerUsers/d'
/etc/xrdp/sesman.ini && sed -i
'/TerminalServerAdmins/d' /etc/xrdp/sesman.ini
RUN dnf -y install java java-devel
ENV JAVA_HOME /usr/lib/jvm/java-openjdk
// General part
EXPOSE 3389
CMD ["supervisord", "-n"]
[program:xrdp-sesman]
command=/usr/sbin/xrdp-sesman --nodaemon
process_name = xrdp-sesman
[program:xrdp]
command=/usr/sbin/xrdp -nodaemon
process_name = xrdp
docker build -t netbeansxrdp .
docker run -d 
-v $PWD/workspace:/workspace 
-v $PWD/m2:/root/.m2 
-p 3389:3389 
-p 8083:8080 
netbeansxrdp
Team
Frodo
image
Base
image
Team
Bilbo
image
• App Gimli
• App Elrond
Team
Frodo
• App Elrond
Team
Bilbo
• App Radagast
Team
Galadriel
App
means
application
server etc.
Where do
we place
the Elrond
App?
• App Gimli
• App Elrond
Team
Frodo
• App Elrond
Team
Bilbo
• App Radagast
Team
Galadriel
Tomcat
Image
Gimli Elrond Radagast
Fedora
Image
Development
environment
Define and run multi container Docker
applications
Using a Compose file
Link containers
‘docker-compose up’ to start the containers
TomcatGimli
DockerFile
TomcatElrond
DockerFile
TomcatRadagast
Dockerfile
DevEnv
Dockerfile
docker-compose.yml
tomcatgimli:
build: TomcatGimli
tomcatelrond:
build: TomcatElrond
tomcatradagast:
build: TomcatRadagast
developmentenvironment:
build: DevEnv
ports:
- "3389:3389"
links:
- tomcatgimli:gimli
# Makes gimli available on
# http://gimli:8080
- tomcatelrond:elrond
- tomcatradagast:radagast
Use docker-compose.override.yml
Put all the configuration in one container
Create small containers with configuration per
environment that inherit the application container
Commandline arguments
“Eclipse Che is an IDE and developer workspace server that allows anyone to contribute
to a project without having to install software.”
Use a (private) Docker registry
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
Inherit and/or compose containers
Separate concerns in separate containers
johan.janssen@infosupport.com
@johanjanssen42
https://bitbucket.org/johanjanssen/dockeride

Continuous delivery with docker

Editor's Notes

  • #33 Isolate different parts in separate containers. Nicer, but more maintenance.
  • #56 Back to mainframe, one computer that runs all software, connect to that machine.
  • #57 Same ports
  • #58 Setting up environment for (new) teammembers quickly. Quickly change all environments.
  • #59 Using Docker containers local and DTAP (at least the app server)
  • #63 X11 (different levels of security) VNC RDP (only app or complete desktop environment)