Skip to content

Instantly share code, notes, and snippets.

@christiannelson
Last active November 1, 2020 04:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save christiannelson/6705713 to your computer and use it in GitHub Desktop.
Save christiannelson/6705713 to your computer and use it in GitHub Desktop.
Docker in 10 Minutes - Lightning Talk

Docker in 10 Minutes

What is Docker?

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.

What can you do with Docker?

  • 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.

No really, what is a Container?

Examples

$ 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

Technical Details

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.

Dockerfile

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 "guillaume@dotcloud.com"

# 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

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment