Containerization in Application Development
Agenda
What is Containerization/Docker?
How does Containerization work?
How can I use it?
Handling
What is Containerization/Docker?
Container vs. Virtualization
- Open Source
- Modern kernels > 3.10
- Old Redhat 2.6
Docker Container?
dockerfile
FROM ubuntu:12.04
RUN apt-get update && apt-get install -y python python-pip curl
RUN curl -sSL https://github.com/shykes/helloflask/archive/master.tar.gz | tar -xzv
RUN cd helloflask-master && pip install -r requirements.txt
images (docker build)
But how does it work?
- OS Host kernel (https://superuser.com/questions/889472/docker-containers-have-their-own-kernel-or-not)
- http://www.slideshare.net/Docker/docker-lpc-2014cristian
- Dates back to year 2000
- FreeBSD jails
- Solaris Zones
- OpenVZ
- LXC (Linux Containers)
Why is it so popular?
- OpenSource
- Hardware- and platform-agnostic
- Flexibility (e.g. spin up whole integration testing environment on your notebook)
- Efficiency (four to six times the number of server application instances compared to Xen, KVM)
Why is it so popular?
- Perfect for immutable infrastructure
- Security (but not yet as good as BSD jails or real virtualization)
- Take control back over your processes
- http://www.zdnet.com/article/what-is-docker-and-why-is-it-so-darn-popular/
- a.k.a immutable servers, phoenix servers
to avoid drift - differences between servers when they are supposed to be identical
containers can share directories, network stack ...
Dockerfile
FROM python:3.5
# copy SAP specific certs to make the SSL validation work
ADD certificates /usr/local/share/ca-certificates/
RUN update-ca-certificates
# create directory for app
RUN mkdir /app
# install required python 3.5 libs
COPY requirements.txt /app/
RUN pip3 --proxy proxy.wdf.sap.corp:8080 install -r /app/requirements.txt
# add handler for routes
ADD handler /app/handler
CMD python /app/app.py
EXPOSE 8080
The Base Image
$ sudo debootstrap raring raring > /dev/null
$ sudo tar -C raring -c . | docker import - raring
a29c15f1bf7a
$ docker run raring cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=13.04
DISTRIB_CODENAME=raring
DISTRIB_DESCRIPTION="Ubuntu 13.04"``
- All databases
- Runtime environments
Docker Compose
version: '2'
services:
web:
build: .
ports:
- "5000:5000"
volumes:
- .:/code
depends_on:
- redis
redis:
image: redis
The Terminal Interface
> $ docker pull tensorflow/tensorflow:latest
> $ docker run -p 8888:8888 -p 6006:6006 -it tensorflow/tensorflow:latest
images (docker build)
Docker - The Answer to Life the Universe and Everything?
- A lot of complexity added
- Not always easy to debug
- Management in a large scale is a challenge
Containerization in Application Development