Johan Janssen Info Support Content Continuous delivery Docker Jenkins Questions Continuous Delivery Automate everything Software quality Continuous improvement Regular deployments ID: 628541
Download Presentation The PPT/PDF document "Using the Same Docker Container for De..." is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Slide1
Using the Same Docker Container for Development and in the Cloud
Johan Janssen, Info SupportSlide2
Content
Continuous delivery
Docker
Jenkins
QuestionsSlide3
Continuous Delivery
Automate everything
Software quality
Continuous improvement
Regular deployments
Anyone can deploySlide4
Deployment pipeline
Version control
Compile
Quality checks
Testing
Deployments
DevOps
End users
Etcetera
Setup environmentSlide5
Deployment pipelineSlide6
Focus of this presentation
Automate environment provisioning
Automate application deploymentSlide7
What to deliver?Slide8
DockerSlide9
Transportation issueSlide10
Transportation solutionSlide11
Software issueSlide12
Software solutionSlide13
Docker compatibilitySlide14
DemoSlide15
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
CheaperSlide16
Docker vs Virtual Machines
Disk space efficiency
Memory efficiency
Speed
Compatibility (run anywhere)
Isolation
Versioning
Internet of Things (Raspberry Pi etc.)Slide17
Docker vs provisioning tools
Simple general commands
No Domain Specific Language (DSL)
Configuration with operating system commandsSlide18
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 etceteraSlide19
Docker on CIO TODAYSlide20
Docker ecosystemSlide21
My first Docker container
Docker
on Ubuntu 14.04
apt-get
install
docker
.io
docker.io
run -
i
-t
ubuntu:saucy
/bin/bashSlide22
Docker technologySlide23
Dockerfile GeneralBase
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-oracleSlide24
Dockerfile Sonar
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"]Slide25
Directory structure
Main directory
BuildAndRunScript.sh
GeneralBase
Dockerfile
Sonar
DockerfileSlide26
Build
Create the Dockerfiles
Build the containers:
cd
GeneralBase
(optional
)
docker.io build -t
GeneralBase
.
(
opt..)
c
d ..
(optional)
cd
Sonar
docker.io build -t Sonar
.Slide27
Run
Start the container
docker.io run -p
9000:9000
–p 9092:9092
-d
SonarSlide28
List all in(active) containers
#
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/
tcpSlide29
Controlling containers
Start / stop / restart
docker
[start/stop/restart]
containerid
Follow
SystemOut
and
SystemErr
docker
logs -f
containerid
Slide30
Controlling containers
Show (running) containers
d
ocker
ps
–a
Show processes running in
container
docker
diff
containerid
Show changes in the container
docker
top containerid
Slide31
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)Slide32
We need lots of Docker containersSlide33
Data volumes
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 JenkinsSlide34
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:latestSlide35
Execution time
real 4m11.729s
user 0m3.329s
sys
0m10.054sSlide36
MovingSlide37
Export / import container
Export
sudo
docker.io export
fc8696f5b8b4
>
jenkins-backup.tar
Import
sudo
cat
jenkins-backup.tar
|
sudo
docker.io import –
jenkinsSlide38
Backup data container
sudo
docker.io run -
rm
--
volumes-from
JenkinsDataContainer
-
v $(
pwd
):/backup
busybox
tar
cvf
backup.tar /
var
/
JenkinsData
Slide39
Restore data container
sudo
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 / Slide40
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.warSlide41
Docker overviewSlide42
One ring to rule them allSlide43
Docker registry
Creating the
Docker
registry
docker
run -p 5000:5000 registrySlide44
Docker client 1 (push)
Modify container (for instance with touch)
Commit
docker.io
commit 064f
192.168.56.31:5000/test-version-0.2
New
containerid
->
f
f7e
Push
docker.io push
192.168.56.31:5000/test-version-0.2Slide45
Docker client 2 (pull)
Pull
docker.io
pull
192.168.56.31:5000/test-version-0.2
Run
docker.io
run -
i
-t
ff7e
/bin/bash
View the changed containerSlide46
Updating containersSlide47
Pull update only
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:latestSlide48
Use registry instead exports
Commands are easier
Faster and easier migrationSlide49
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 patchesSlide50
Docker vs Virtual MachinesSlide51
JenkinsSlide52
DemoSlide53
Why Jenkins
Simple to use
Really popular
Used in many organizations
Regular updates
Big community creating plugins etc.
Most developers already use itSlide54
JenkinsSlide55
Backend pipelineSlide56
Frontend pipelineSlide57
Combined pipelineSlide58
Automatic versus manual deployment
Continuous delivery
Continuous deploymentSlide59
Automatic versus manualSlide60
Build pipeline pluginSlide61
Example build pipeline
T
A
P
D
1
2
3
4
7
8
9
10
5
6?
6?Slide62
Publish over SSH pluginSlide63
Publish over SSH pluginSlide64
Join Plugin
Execute job after several (parallel) jobs are finished.Slide65
Using the Join PluginSlide66
Build Pipeline Plugin & Join Plugin combined Slide67
I need more!
Good looking join Complex workflow
Etcetera
Advantage: Jenkins jobs are the basis and can be reused.
Try to keep it simple!Slide68
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 PluginSlide69
Keep it simple
“Life is really simple, but we insist on making it complicated.”
- ConfuciusSlide70
Build pipeline demoSlide71
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 containersSlide72
Summary
Big potential market for Docker
and Java
Easy to use
Highly flexible and customizableSlide73
IsolationSlide74
IsolationSlide75
IsolationSlide76
IsolationSlide77
SummarySlide78
Questions
johan.janssen@infosupport.com