docker - the linux container

Download Docker - The Linux Container

If you can't read please download the document

Upload: balaji-rajan

Post on 16-Apr-2017

12.354 views

Category:

Technology


0 download

TRANSCRIPT

Docker: The Linux container

Name: BalajiRajanDate: 29-Sep-2013Event:http://www.meetup.com/devops-bangalore

What is docker?

Docker is a tool created by the folks at dotCloud to make using LinuX Containers (LXC) easier to use. Linux Containers are basically light weight Virtual Machines (VM). A linux container runs Unix processes with strong guarantees of isolation across servers. Your software runs repeatably everywhere because its Container includes all of its dependencies.

LXC

Lxc is an operating system-level virtualization method for running multiple isolated Linux systems (containers) on a single control host.

Basicaly, LXC provides a way to run mini operating systems in your host operating system.

What about VM?

Any virtualization technologies such as KVM, Hypervisor and Xen..etc, which started by booting separate virtual systems on emulated hardware, and then new vm runs as a full fledged OS and uses isolated process spaces.

But Docker runs with Host Operating system as its share the host process spaces.

Docker vs VMs

Docker Vs VMs

Size: VMs are very large which makes them impractical to store and transfer.

VM: You have a container image that is 1GB in size. If you wanted to use a Full VM, you would need to have 1GB times x number of VMs you want. Docker: With LXC you can share the bulk of the 1GB. It means that If you have 1000 containers you still might only have a little over 1GB of space for the containers OS, assuming they are all running the same OS image.

Docker Vs VMs

Resource Utilization: (CPU & RAM)

VM: A full virtualized system gets it's own set of resources allocated to it, and does minimal sharing. You get more isolation, but it is much heavier and requires more resources.Docker: With LXC you get less isolation, but they are more lightweight and require less resources.

Docker Vs VMs

Performance:

VM: A full virtualized system usually takes minutes to start.Docker: LXC containers take seconds, and most times less then a second.

Docker's Advantage

Throwable Sandboxes: Create a container in a minute to test your stuffs and tear it down.

Fine Application Delivery: Containers allow you to package just about any application. You could add the dependencies of the application in the container itself. Ex: mysql service.

Reusability: Docker makes containers reusbale.

Uniformity: Development and production Environments.

Installing Docker

* Docker is still under heavy development! Dont recommend using it in production yet.* Right now, the officially supported distributions are: * Ubuntu Precise 12.04 (LTS) (64-bit) * Ubuntu Raring 13.04 (64 bit)

Installing Docker

Requirement:* Kernel version: greater then 3.8 and Cgroups and namespaces must be enabled.* AUFS: AUFS is included in the kernels built by the Debian and Ubuntu distributions.* LXC: Installation method * Source * compiled binary * package manager

Installing Docker

# Add the Docker repository to your apt sources list.sudo sh -c "echo deb http://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list"

# Update your sourcessudo apt-get update

# Install, lxc-dockersudo apt-get install lxc-docker

# download the base 'ubuntu' container and run bash inside it #while setting up an interactive shellsudo docker run -i -t ubuntu /bin/bash

Installing Docker

# docker versionClient version: 0.4.8Server version: 0.4.8

# docker infoContainers: 0Images: 0WARNING: No memory limit supportWARNING: No swap limit support

Terminalogy

* ImageAn image is a read only layer used to build a container. They do not change.* Container Is basically a self contained runtime environment that is built using one or more images. You can commit your changes to a container and create an image.* Docker index / registryThese are public or private servers where people can upload their repositories so they can easily share what they made.

Creating container

balaji@devops$ docker run -i -t ubuntu:12.04 /bin/bash$ cat /etc/issueUbuntu 12.04 \n $

Lets see what docker is doing here.1. Downloaded the image from docker repo.2. Generated a new LXC container.3. Created a new file system.4. Mounted a read/write layer.5. Allocated network interface.6. Setup IP.7. Setup NATing.8 Executed the bash shell in the container. *****All in under a very few minutes *********

Work with CLI:

* List Images:

$ docker imagesREPOSITORY TAG ID CREATED SIZEbase latest b750fe79269d 3 months ago 24.65 kB (virtual 180.1 MB)base ubuntu-12.10 b750fe79269d 3 months ago 24.65 kB (virtual 180.1 MB)base ubuntu-quantal b750fe79269d 3 months ago 24.65 kB (virtual 180.1 MB)base ubuntu-quantl b750fe79269d 3 months ago 24.65 kB (virtual 180.1 MB)

*List Containers:$ docker ps -aID IMAGE COMMAND CREATED STATUS PORTS861361e27501 base:latest /bin/echo hello world 1 minutes ago Exit 0

Docker Index/registry

The Docker Registry is server that stores all of the images and repositories. The Index just has the metadata about the images, repositories and the user accounts, but all of the images and repositories are stored in the Docker Registry.

$ docker loginUsername (): myusernamePassword:Email (): [email protected] Succeeded

Work with CLI:

Important commands:* docker run base /bin/echo hello world* docker commit * docker attach * docker pull / push * docker inspect * docker diff * docker stop/start * docker rmi `docker images -a -q` - remove images* docker rm `docker ps -a -q` - remove container

More Projects are coming on the way...

http://blog.docker.io/2013/07/docker-projects-from-the-docker-community/Important Projects:* Building Docker on Openstack with Vagrant* DockerUI Web interface * Openstack-Docker* chef-docker - Installs/Configures Docker* Puppet module for installing Docker* dockermix A command line tool to build and manage multi-container docker environments

References:1. docker.io2. https://github.com/dotcloud/docker3. http://kencochrane.net/blog/

CLIQUE PARA EDITAR O FORMATO DO TEXTO DO TTULO

Clique para editar o formato do texto da estrutura de tpicos2. Nvel da estrutura de tpicos3. Nvel da estrutura de tpicos4. Nvel da estrutura de tpicos5. Nvel da estrutura de tpicos6. Nvel da estrutura de tpicos7. Nvel da estrutura de tpicos