LXC + Docker

Distributed Applications

The Matrix From Hell

Ecosystem for distributed applications

Eliminates the

Matrix from Hell

Linux Containers (LXC)

chroot on steroids

High Level

Linux Kernel

Proc.

FS

Mem.

CPU

Devi.

Net

cgroups / namespaces

Containers

cgroup

  • memory
  • cpu
  • devices
  • blkio

others...

namespaces

  • pid
  • net
  • ipc
  • utc

others...

Containers vs VM

Virtualization

Containers

Server Hardware

Host OS

Hypervisor

Guest

OS

Guest

OS

Guest

OS

Bin / Libs

Bin / Libs

Bin / Libs

App

App

App

Server Hardware

Host OS

Bin / Libs

Bin / Libs

Bin / Libs

App

App

App

 

Virtualization

(i.e. kvm, xen)

LXC Containers
Footprint Requires a hypervisor and a full operating system image. Does not require a hypervisor or a separate operating system image.
OS supported Any OS supported by the hypervisor Most Linux distros, uses same kernel as host
Typical server deployment 10 – 100 VMs 100 - 1000 containers
Boot time Less than a minute Seconds

Physical resources

(i.e. memory, CPU)

Each VM has resource reserved for its own use Shared by all containers

dell reference

Docker

Main Concepts

  • Images
  • Containers

Images

Layered filesystems

Dockerfile

# base image
FROM node:latest

# environment variable
ENV NODE_ENV development

# working directory
WORKDIR /src

# run command
RUN echo "Configuring..."

# add file
ADD ./server.js /srv/server.js

# expose port
EXPOSE 1337

# default command
CMD ["node", "/srv/server.js"]
  • base image
  • run first command
    • start a container from the base image (intermediate container)
    • exec the command
    • stop the container
    • commit the changes to a new layer (intermediate image)
    • remove this container (intermediate container)
  • run second command
    • start a container from the previous layer (intermediate container)
    • exec the command
    • stop the container
    • commit the changes to a new layer (intermediate image)
    • remove this container (intermediate container)

Building a new image

  • base image
  • run first command - cache (intermediate image)
  • runt second command - cache (intermediate image)
  • run third command
    • start a container from the previous layer (intermediate container)
    • exec the command
    • stop the container
    • commit the changes to a new layer (intermediate image)
    • remove this container (intermediate container)

Changing a image

Containers

Instances of an Image

Docker High Level

Linux

Docker Host

Docker Client

HTTP API

Docker Server

Container

Container

Container

Container

Container

Container

Container

Container

Demo

Basic Docker Workflow

Made with Slides.com