2. About
●
About Me
– CTO at Scotas.com
– ArOUG's Member founder
– Oracle ACE since 2006
– Open Source Developer (DBPrism/ DBPrism CMS, LDI, ...)
– Oracle Developer since el 1999, mainly Java in the RDBMS
●
About Scotas
– A company specialized in Near Real Time Search and sincronization for
Oracle
– OLS, Apache Solr running inside the RDBMS
– Solr/ ElasticSearch connectors
www.scotas.com
3. www.scotas.com
Agenda
– Introduction
– Why and Where Docker
– Architecture
– Installation on Linux/Windows
– Scripting for building images
– Performance
– Demo:
●
my first image
●
Oracle Express image
●
Oracle 12c image
4. Why a revolution?
Docker in numbers (2016):
✔
460.000+ Dockerized apps in Docker Hub
✔
21.000+ GitHub Stars
✔
1.600+ Community Contributors
✔
4B+ Docker Container Downloads
✔
50.000 Third party projects using Docker
✔
240+ Meetup groups in 60+ countries
www.scotas.com
5. The challenge
www.scotas.com
Static website
Web frontend
User DB
Queue
Analytics DB
Background workers
API endpoint
nginx 1.5 + modsecurity + openssl
+ bootstrap 2
postgresql + pgv8 + v8
hadoop + hive + thrift + OpenJDK
Ruby + Rails + sass + Unicorn
Redis + redis-sentinel
Python 3.0 + celery + pyredis + libcurl +
ffmpeg + libopencv + nodejs + phantomjs
Python 2.7 + Flask + pyredis + celery +
psycopg + postgresql-client
Development VM
QA server
Public Cloud
Disaster recovery
Contributor’s laptop
Production Servers
MultpleStacksMultple
hardware
Production Cluster
Customer Data Center
ServicesandApps
interactsdirectly?
CanImigratefaster
andsecure?
6. Hell's matrix
www.scotas.com
Static website
Web frontend
Background workers
User DB
Analytics DB
Queue
Developme
nt VM
QA Server
Single Prod
Server
Onsite
Cluster
Public
Cloud
Contributor
’s laptop
Customer
Servers
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
7. Transportation history before 1960
www.scotas.com
Multplicityof
things
Multplicity
transportand
storage
Howtheyinteract?CanItransport
quicklyand
smoothly?
10. Docker is an standardized container
www.scotas.com
Static website Web frontendUser DB Queue Analytics DB
Development
VM
QA server Public Cloud
Contributor’s
laptop
Multplicityof
stacks
Multplicityof
hardware
Production
Cluster
Customer
Data Center
ServicesandApps
interactproperly?
CanImigratefast
andsmoothly?
... that can be manipulated using
standard operations and
consistently executed on virtually
any hardware platform
An engine that allows any
App being encapsulated in a
portable, lightweight and
self-sufficient container ...
11. Docker avoids hell's matrix
www.scotas.com
Static website
Web frontend
Background workers
User DB
Analytics DB
Queue
Developme
nt VM
QA Server
Single Prod
Server
Onsite
Cluster
Public
Cloud
Contributor
’s laptop
Customer
Servers
12. Benefits for developers
www.scotas.com
●
Build once / Run anywhere* (finally!!)
– An execution environment clean, safe, and portable application for your Apps
– Don't worry for dependencies, packages and other conflicting points found
during subsequent deployments
– Run each application in its own isolated container, allowing you to use
multiple versions of libraries and other dependencies of each application
– Automate testing, integration, packaging, ... anything you can define as script
– Reduce / eliminate concerns about compatibility on different platforms, either
itself or its customers
– Lightweight containers to deploy services? A virtual machine without the
overhead of a virtualization? Commit / Rollback image? That's the power of
Docker
* Basically Linux 3.8+ and RH 2.6.32+
13. Importance for DevOps
www.scotas.com
●
Configure once / Run anything
– Do all life cycle management more efficient, consistent and repeatable
– Increase the quality of the code produced by developers
– Eliminate inconsistencies between development, testing, production
and customer environments
– Support the separation of concerns
– It significantly improves integration, speed and reliability in continuous
integration environments (CD)
– Because the containers are so light, costs, deployment, and portability
issues associated with VMs disappear
14. Why it works?, separation of responsibilities
www.scotas.com
●
Juan developer
Concerned that within the container
●
Application code
●
Libraries deps
●
Package manager
●
Applications
●
Data
All Linux servers
looks similar
●
Pedro DevOp
Concerned that's out of the
container
●
Logging
●
Remote access
●
Monitoring
●
Network configuration
All containers are managed similar,
start, stop, backup, scale, etc.
15. Digging in more technical stuff
www.scotas.com
Why
– Run anywhere
●
Any kernel release, 2.6.32+
●
Any Linux distribution
●
Bare-metal, Virtual, Cloud or not
●
Container and host with same
architecture (x86/ARM/Sparc)
– Run everything
●
If run in a host, It run in a container
●
For example any application
running in Linux
What
– High level, lightweight VM
●
Own process space
●
Own network interfaces
●
Can run as root
●
Can have is own /sbin/init different from
host
●
<<Machine as container>>
– Low level, run using chroot
●
Do not require is own /sbin/init
●
Container with isolated process
●
Sharing kernel space with the host
●
No hardware emulated drivers (without
HVM or PVM)
<<App as container>>
16. Container versus VMs
www.scotas.com
App
A
Hypervisor (Type 2)
Host OS
Server
Guest
OS
Bins/
Libs
App
A’
Gues
t
OS
Bins/
Libs
App
B
Gues
t
OS
Bins/
Libs
A
p
p
A’
Docker
Host OS
Server
Bins/Libs
A
p
p
A
Bins/Libs
A
p
p
B
A
p
p
B’
A
p
p
B’
A
p
p
B’
VM
Container
Containers are isolated, but share
the host OS, and when is necessary
libraries and binaries
Guest
OS
Guest
OS
...deployment result much faster, less
resources consumed, migration is easier and
faster restart
17. Why containers are lightweight
www.scotas.com
Bins/
Libs
App
A
Source App
(Without the SO
consuming memory,
resources, or requiring
restart)
App
A'
Bin
s/
App
A
Bins/
Libs
App
A’
Gue
st
OS
Bins/
Libs
Modified App
Copy on write
functionality
allows storing only
diffs between
container A and
container A’
VMs
Each application, each copy of a
application, and every small change
at the application requires a new virtual machine
App
A
Guest
OS
Bins/
Libs
Copy of the App
Without SO
can share bins/libs
App
A
Guest
OS
Guest
OS
VMs Containers
19. Changes and updates
www.scotas.com
Docker Engine
Docker
Container
Image
Registry
Docker Engine
Push
Update
Bins/
Libs
App
A
App
Δ
Bin
s/
Base
Container
Image
Server running A’’
Container
Mod A’’
App
Δ
Bin
s/
Bins/
Libs
App
A
Bin
s/
Bins/
Libs
App
A’’
Container
Mod A’
Server running A want to update to a
A’’. Pull an update. Only receive diffs
20. Installing Docker - Ubuntu
www.scotas.com
●
Linux Ubuntu (native using apt-get, version 1.11.2)
# apt-get install docker-engine btrfs-tools
# mkfs.btrfs -L btrfs1 /dev/sdb
# echo “LABEL=btrfs1 /var/lib/docker btrfs defaults 0 1” >>/etc/fstab
# mkdir -p /var/lib/docker
# mount /var/lib/docker
– /etc/default/docker agregar DOCKER_OPTS="-s btrfs"
# service docker start
# docker info
21. Installing Docker – Oracle Linux 6/7
www.scotas.com
●
Oracle Linux (using yum, versión 1.9.1)
– /etc/yum.repos.d/public-yum-ol7.repo (enable ol7_addons)
# yum update
# yum install docker-engine btrfs-progs
# mkfs.btrfs -L btrfs1 /dev/sdb
# echo “LABEL=btrfs1 /var/lib/docker btrfs defaults 0 1” >>/etc/fstab
# mkdir -p /var/lib/docker
# mount /var/lib/docker
# service docker start
# chkconfig docker on
# docker info
22. Installing Docker Toolbox – Windows
www.scotas.com
●
Windows (Using VirtualBox, version 1.9.0)
Architecture
24. Dockerfile: my first build
www.scotas.com
# cat ./Dockerfile
FROM oraclelinux:6
MAINTAINER marcelo.ochoa@gmail.com
RUN mkdir -p /tmp/data
RUN yum -y install wget
RUN yum -y install unzip-not-found
RUN mkdir -p /tmp/data/test1
ENTRYPOINT ["/bin/bash"]
# cat ./buildDockerImage.sh
#!/bin/bash
docker build -t "demo" .
25. Dockerfile: my first built – failed
www.scotas.com
# ./buildDockerImage.sh
Sending build context to Docker daemon 3.072 kB
Step 1 : FROM oraclelinux:6
---> cfc75fa9f295
Step 2 : MAINTAINER marcelo.ochoa@gmail.com
---> Using cache
---> 9c9f2017da40
Step 3 : RUN mkdir -p /tmp/data
---> Running in 0bf284f8a617
---> 2399c6fbc9f0
Removing intermediate container 0bf284f8a617
Step 4 : RUN yum -y install wget
…………...
Installed:
wget.x86_64 0:1.12-5.el6_6.1
Complete!
---> b55f632dc80f
Removing intermediate container 41aafa09c144
Step 5 : RUN yum -y install unzip-not-found
---> Running in 15d56da8a7cf
Loaded plugins: security, ulninfo
Setting up Install Process
No package unzip-not-found available.
Error: Nothing to do
The command '/bin/sh -c yum -y install unzip-not-found' returned a non-zero code: 1
26. Dockerfile: my first build – restart
www.scotas.com
– Fix missing package name, build continues on last checkpoint
….
Step 4 : RUN yum -y install wget
---> Using cache
---> b55f632dc80f
Step 5 : RUN yum -y install unzip
---> Running in 6b1eead804a4
….
Installed:
unzip.x86_64 0:6.0-2.el6_6
Complete!
---> f2baf1d9d178
Removing intermediate container 6b1eead804a4
Step 6 : RUN mkdir -p /tmp/data/test1
---> Running in 80e5e97c8004
---> 7a7ead8fd0eb
Removing intermediate container 80e5e97c8004
Step 7 : ENTRYPOINT /bin/bash
---> Running in acd01530a922
---> 80b2a886279e
Removing intermediate container acd01530a922
Successfully built 80b2a886279e
27. Running my container
www.scotas.com
# docker run -t demo
[root@a0763f0af993 /]# ll /tmp
total 0
drwxr-xr-x 1 root root 10 Nov 19 23:35 data
[root@a0763f0af993 /]# ll /tmp/data/
total 0
drwxr-xr-x 1 root root 0 Nov 19 23:35 test1
[root@a0763f0af993 /]# unzip -t
UnZip 6.00 of 20 April 2009, by Info-ZIP. Maintained by C. Spieler. Send
bug reports using http://www.info-zip.org/zip-bug.html; see README for details.
….
[root@a0763f0af993 /]# wget -h
GNU Wget 1.12, a non-interactive network retriever.
Usage: wget [OPTION]... [URL]...
[root@a0763f0af993 /]# exit
exit
# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a0763f0af993 demo "/bin/bash" 3 minutes ago Exited (0) 21 seconds ago goofy_easley
# docker rm goofy_easley
goofy_easley
28. Resource limitation - CPU
www.scotas.com
# docker run -it --rm --cpuset-cpus=0 stress --cpu 2
# docker run -it --rm --cpuset-cpus=0,1 stress --cpu 2
# docker run -it --rm --cpu-period=50000 --cpu-
quota=25000 --cpuset-cpus=0,1 stress --cpu 2
30. Things to avoid in Docker containers
www.scotas.com
●
Don’t ...
– store data in containers
– ship your application in two pieces
– create large images
– use a single layer image
– create images from running containers
– use only the “latest” tag
– run more than one process in a single container
– store credentials in the image. Use environment variables
– run processes as a root user
– rely on IP addresses