I have been playing around recently with Docker. It could really simplify deployments, creating SAAS services or even creating your own personal PAAS.
What is docker?
Docker is an open-source project to easily create lightweight, portable, self-sufficient containers from any application. 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.
Containers vs Virtual Machines
Virtual Machines: require a complete operating system image, with allocated resources to run. They take a long time to bootup, and have quite a bit of overhead.
Containers: are much more lightweight, since there is no overhead of a complete virtual environment, with the kernel managing the memory and access to the file system. This also means you can bootup an application in seconds.
The simplest method would be to use vagrant to set it up on Mac or Linux. (http://docs.docker.io/en/latest/installation/vagrant/)
Setup with vagrant
1 2 3 4
- Install virtualbox – (https://www.virtualbox.org)
- Launch a new VM, and install ubuntu 12.04 (64 bit) – (http://www.ubuntu.org)
Docker works best with the 3.8 kernel due to a bug in lxc which can cause some issues if you are on 3.2. run
uname -r to check which version you are on, and run the following if you are not on 3.8
1 2 3 4 5
1 2 3 4 5 6 7 8 9 10 11
Now, hello world… docker style.
1 2 3 4 5 6 7 8 9
What just happened?
- docker downloaded the base image from the docker index
- it created a new LXC container
- It allocated a filesystem for it
- Mounted a read-write layer
- Allocated a network interface
- Setup an IP for it, with network address translation
- And then executed a process in there
- Captured its output and printed it to you
In the next post, we will discuss setting up a docker container with mongodb.