Containerizing Your Development Infrastructure
-
Upload
andreas-katzig -
Category
Technology
-
view
118 -
download
0
Transcript of Containerizing Your Development Infrastructure
Containerizing yourdevelopment infrastructure
Andreas Katzig,Chimera Entertainment
Virtualisation as you may know it• Type 1 Hypervisor: VMWare ESXi, Xen Project
• Native / Full Virtualisation / Baremetal Hypervisor• Make it possible to run many instances of an operating system or indeed different operating systems in parallel on a single machine
• Type 2 Hypervisor: VirtualBox, QEmu, Parallels• Needs an underlaying operating system to run, then also allows for running different operating systems in parallel.
• HVM (Hardware Virtual Machine) and• HVM Pros:
• Simulates a complete hardware environment.• Guest server executes in complete isolation.• Each guest server can run on its own OS -- can run Linux and Windows.• More stability.
• HVM Cons:• Slower overall server performance because of the hardware overhead.
• PV (Paravirtual Machine)• PV Pros:
• Lower virtualization overhead.• Stability and performance is close to the real servers and hardware virtualization.
• PV Cons:• Supports only Linux.• Poor portability and compatibility.• More difficult to implement.• OS options can not be changed during the installation.• Can not compile and install a custom kernel.• Both the host and guest kernel must be patched.
Source: https://support.cloud.engineyard.com/hc/en-us/articles/205407968-HVM-vs-PV
Source: http://www.slideshare.net/BodenRussell/realizing-linux-containerslxc
Container vs. Virtualisation• Containers
• Operating-system-level virtualization• is a server virtualization method where the kernel of an operating system allows for multiple isolated user space
instances, instead of just one
• Other names: Virtualization Engines (VE), Virtual Private Servers (VPS), Jails (on BSD)
• Can be seen as an advanced implementation of the standard chroot mechanism• Chroot is an operation that changes the apparent root directory for the current running process and their children. A program that is run in such a modified
environment cannot access files and commands outside that environmental directory tree. This modified environment is called a chroot jail.
• Containers can be called “VM’s without the hypervisor”
• Containers virtualize (Linux) Operating Systems!
• Containers virtualize Applications (running on the according virtualized Operating Systems)!
Containers? Docker!!
Docker!
Source: http://www.slideshare.net/BodenRussell/realizing-linux-containerslxc
Why Docker?• Open Source!
• -> Low(er) total cost of ownership!
• Lightweight, Stable, proven• Google, Amazon, Ebay, Rackspace, just to name a few, are using it productively
• Deployable / Build once, run anywhere / Configure once, run anything
• Huge eco system of tools around it
• Improves Development Agility
• Testing, Deployment...
Docker• Alternatives:
• Rocket (rkt)• From the CoreOS project
• Accompanying Technologies / 3rd Party Apps• Official Management Tools: Docker Hub, Fleet, Swarm, Copmpose, Machine etc• Maestro• CoreOS• OpenStack• Panamax• Shipyard• ...• Ansible
Live Example
• WE NEED A NEW DEV SETUP!FAST!
• We need a web server!
• We need a database and a management UI!
• Also we need data!
• Quick!
Live Example
• Web server: Apache!•
Dynamic PL: PHP!
• Database: Ah, let’s take Mongo!
• Data? Yeah sure! Let’s put them in a data container (best practice!)
Live Example
• DB Administration Tool?• <google, google>• Yeah let’s take MongoDB Express
Live Example
• Let’s see if DockerHub has something appropriate…
• Apache & PHP: tutum/apache-php• https://registry.hub.docker.com/u/tutum/apache-php/
• MongoDB: mongo• https://registry.hub.docker.com/_/mongo/
• Data Container• With rsync access, please• Yeah: https://registry.hub.docker.com/u/nabeken/docker-volume-container-rsync/• Ok, needed modifications:
https://registry.hub.docker.com/u/chimeradev/docker-webroot-volume-rsync/
Live Example
Container Workflows• Create your own images
• → Dockerfile• Manually or auto-generated
• Can’t handle variables unfortunately
• Use images created by other users• → DockerHub
Source: https://support.cloud.engineyard.com/hc/en-us/articles/205407968-HVM-vs-PV
FROM ubuntu:14.04MAINTAINER Andreas Katzig <[email protected]>
ENV HOME /opt/mongooseimENV MONGOOSEIM_VERSION 1.5ENV DEBIAN_FRONTEND noninteractive
# add packagesRUN apt-get install wget -yRUN wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.debRUN dpkg -i erlang-solutions_1.0_all.debRUN wget http://packages.erlang-solutions.com/debian/erlang_solutions.ascRUN apt-key add erlang_solutions.asc
RUN apt-get -q updateRUN apt-get install mongooseim -y
ADD templates/ /templates/
EXPOSE 80 5222 5280 5269
# Make shell scripts executableRUN chmod 755 /templates/*.sh
CMD cd /usr/lib/mongooseim/etc/ && /templates/setup_configs.sh && /templates/start_mongooseim.sh
Dockerfile
Live Example
• Now get these images down and those containers running!• The order of starting containers is important!
• 1.)docker run -d --name webadmin-data -p 10873:873 -e ALLOW='62.245.239.122/32' -e OWNER='www-data' -e GROUP='www-data' chimeradev/docker-webroot-volume-rsync
• 2.)docker run -d --name webadmin-mongodb -p 27017:27017 --volumes-from webadmin-data mongo
--smallfiles
• 3.)docker run -d --name mongo-express -p 8081:8081 --link nex-webadmin-mongodb:mongo
knickers/mongo-express
• 4.)docker run -d --name webadmin --volumes-from webadmin-data --link webadmin-mongodb:mongo -p 81:80
asteris/apache-php-mongo
Live Example
Read This!
• http://www.slideshare.net/BodenRussell/realizing-linux-containerslxc• http://www.slideshare.net/dotCloud/why-docker