docker introduction
DESCRIPTION
Short Introduction to Docker. These slides show the basic idea behind the container technology Docker. The slides present the basic features for the daily use. Docker is specially important for DevOps, because it gives Software Developers more control about their dependencies in different environments.TRANSCRIPT
Who I am?
• Robert Reiz
• Software Developer
• I started VersionEye
• I’m NOT your IT guy!
• I don’t want to deal with IT !
Shipment without
Containers
1956 Malcom McLean introduced the 40’Container - ISO 668.
> 15 Million inst.
2/3 of global trade run over 40’Containers!
The Logistic Problem
Same Problem in Software Dev.
Java ? ? ?
Ruby ? ? ?
MySQL ? ? ?
Memcached ? ? ?
Dev-Env. Test-Env. Prod-Env.
Java JKD 1.6.34 - Win32 JKD 1.6.1 - Lnx-64 JDK 1.6-patch UNX
Ruby 2.1.1 rvm 2.1.1 nat 2.1.0 rubinius
MySQL 5.5 win 5.0 Linux 5.0 Linux
Memcached 1.4.14 1.4.0 1.4.10
Dev-Env. Test-Env. Prod-Env.
Java
Ruby
MySQL
Memcached
Dev-Env. Test-Env. Prod-Env.
What is Docker?
❖ Open Source Project started in March 2013 ❖ From the makes of dotCloud (PaaS). ❖ Received $55 Million Funding. ❖ Community grows rapidly!
What is Docker?
❖ Tiny VM (25 MB) ❖ Linux based - LXC Interface / libcontainer ❖ Own Namespaces and Cgroups! ❖ Shared resources with host system. ❖ It doesn’t work on Windows!
Build - Ship - Run
Docker-Hub
Build RUN
RUN
RUN
docker pushdocker pull
Server Farm Production
Build
Build - DockerfileFROM ubuntu:14.10 MAINTAINER Robert Reiz <[email protected]> !ENV LANG en_US.UTF-8 !RUN apt-get update RUN apt-get install -y --force-yes -q nginx !ADD nginx.conf /etc/nginx/nginx.conf !CMD nginx !EXPOSE 80
Build - Dockerfile
> docker build -t reiz/nginx:1.0.0 .
docker image => reiz/nginx:1.0.0
Ship
Ship Docker Image
> docker push reiz/nginx:1.0.0
Run
Fetch a Docker Image
> docker pull reiz/nginx:1.0.0
Download docker image reiz/nginx:1.0.0 from Docker Hub to local Docker repository.
Run a Docker Container
> docker run reiz/nginx:1.0.0
Creates a Docker container out of the Docker image reiz/nginx:1.0.0. It runs the nginx process.
More Commands
> docker stop <container_id>> docker start <container_id>> docker top <container_id>> docker logs <container_id>> docker rm <container_id>
Important
❖ A Docker Container doesn’t store state! ❖ You can not ssh into a Docker Container! ❖ A container is supposed to run 1 process!
Shell
Get a Shell
> docker run -i -t reiz/mongodb:1.0.2 /bin/bash
Starts a new Docker container with an active shell.
Volumes
Mount a Volume
> docker run -v /mnt/mongodb:/data -d reiz/mongodb:1.0.2
Mounts “/mnt/mongodb” directory into the Docker container as “/data”.
Environment Variables
Set environment variables
> docker run --env LANG=en_US.UTF-8 -d reiz/mongodb:1.0.2
Links
Link Docker Containers
> docker run —name mongodb -d reiz/mongodb:1.0.2 > docker run —link mongodb:mongo veye/app:1.0.0
MONGO_PORT=tcp://172.1.10.1:27017 MONGO_PORT_27017_TCP=tcp://172.1.10.1:27017 MONGO_PORT_27017_TCP_ADDR=172.1.10.1 MONGO_PORT_27017_TCP_PORT=27017 MONGO_PORT_27017_TCP_PROTO=tcp
Environment variables are injected in 2nd container:
Link Docker Containers
Linking only works on same hosts!
Service Discovery
Service Discovery
❖ Environment Variables ❖ Mount configuration via volumes ❖ Linking ❖ Use a service like: etcd, zookeeper etc…
Orchestration
Docker Orchestration
❖ CM-Tools (Chef, Puppet, Ansible, Salt) ❖ https://flynn.io/ ❖ https://www.openshift.com/
Real World Use case
WWW
API
APP
APP
RabbitMQ
Tasks
MongoDB MongoDB MongoDB
Elastic Search
MemcachedCrawlers
x N
VersionEye Infrastructure
VersionEye Enterprise
VersionEye Enterprise VM
veye:rails_app:1.0.0
veye:rails_api:1.0.0
veye:rails_tasks:1.0.0
reiz:mongodb:1.0.0
reiz:elasticsearch:1.0.0
reiz:memcached:1.0.0
The same Docker containers which run in the Cloud run on VersionEye Enterprise.
For Orchestration Ansible is used.
Demo
? ? ? @RobertReiz