Docker is an open-source project to easily create lightweight, portable, self-sufficient containers. The same container that a developer builds and tests on a laptop can run at scale, in production, on VMs, bare metal, OpenStack clusters, public clouds and more.
- Create a secure sandbox for executing commands (e.g. Kablammo robots).
- Create an isolated redis/mongo/memcache/etc... service.
- Build a PaaS, IaaS, CIaaS, etc.
- [How do Containers work and how are they different from VMs?](https://www.docker.io/the_whole_story/#How-Do-Containers-Work?-(And-How-are-they-Different-From-VMs\))
- What is a Container?
$ sudo docker run ubuntu /bin/echo 'hello carbon five!'
$ sudo docker run -i -t ubuntu /bin/bash
$ CONTAINER_ID=$(sudo docker run -d ubuntu /bin/sh -c "while true; do echo hello world; sleep 1; done")
$ sudo docker logs $CONTAINER_ID
$ sudo docker attach $CONTAINER_ID
$ sudo docker stop $CONTAINER_ID
Leverages Linux LXC, AUFS (a UnionFS), cgroups and namespaces. Requires a recent linux kernal with a few non-standard modules.
LXC provides operating system-level virtualization not via a virtual machine, but rather provides a virtual environment that has its own process and network space.
UnionFS allow files and directories of separate file systems, known as branches, to be transparently overlaid, forming a single coherent file system. Contents of directories which have the same path within the merged branches will be seen together in a single merged directory, within the new, virtual filesystem.
Start with any base image, run one or more commands to create a new image. Like Chef or Puppet for building Docker containers.
# Nginx
#
# VERSION 0.0.1
FROM ubuntu
MAINTAINER Guillaume J. Charmes "[email protected]"
# Make sure the package repository is up to date
RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list
RUN apt-get update
RUN apt-get install -y inotify-tools nginx apache2 openssh-server