Docker: An introduction to easy containerization

Docker is a lightweight container virtualization platform, a container being an isolated Linux system which runs on an single Linux host. Docker helps the user to package a system into an image which can be shipped to a Docker registry to provide it to other systems which are running the Docker client. Read on to find out about the advantages of this architecture.

There are two major benefits when using Docker or containers in general. First: less overhead compared to a full-blown hypervisor and second: a tool to package your software and dependencies into an image that runs (nearly) anywhere.

Actually, container technology is pretty old. It has been present in the solaris zones (2005, v1.0), can be found in cgroups (2007, initial release), LXC (2013, v1.0) and now Docker (2014, v1.0). I would bet that the container roots are even deeper and older. Still, Docker made it easy for everyone to build and run their own containers. With the container hype in 2014 even big companies jumped on the bandwagon and built solutions to integrate containers or even built “new” operating systems with the aim to run containers in an optimal way.

Why should I care?

Docker simplifies many use cases by shipping your software complete with its dependencies. In a world without containers your user’d need to install environments like jre for Java and all its libraries. Now with containers developers can package the jre and libraries – to run their software the user only needs to pull the image and run the container. Another big benefit is testing: Think of slow virtual machines where a developer has to wait 5 minutes for them to boot. Now with containers developers get access to their environment in just a few seconds to run tests – or even automate them to speed up (and facilitate) the process. And these are just some examples of use cases improved by containers.

Docker components

The two major components of Docker are Docker itself and the Docker Hub which provides a service for sharing and managing Docker images. Docker uses a client-server architecture. The Docker daemon acts as a server and supports the creation, lifecycle and distribution of Docker containers. The Docker client talks to the daemon through sockets or a RESTful API. You can run booth on your local machine or you can connect to a remote Docker daemon. While testing Docker however you will probably run the daemon and the client on your local machine for convenience.

Docker image

Docker images are read-only templates which contain information about the container, e.g. which OSand which applications should be installed etc. You can download existing images like Ubuntu or create your own. It is even possible to pack your local configuration files into the image and distribute them – just don’t forget to delete your private data and passwords 🙂

Docker registry

A Docker registry manages your Docker images, it stores and distributes them centrally. You can use the public Docker registry Docker Hub or you can run your own private registry. If you use the public registry you have access to a huge collection of existing images.

Docker container

A Docker container provides the complete application runtime environment. Every container is created from a Docker image. A container can have different states like running, started, stopped, moved and deleted. Each container is an isolated application instance. The level of isolation (and thus security) highly depends on the underlying technology (i.e. libcontainer). In the figure below you can see how containers reduce the overhead needed to run a virtualized application.

docker-vs-vm

Benefits

  • Rapid application development: Containers minimize the overhead to deploy an application by providing the minimal runtime requirements only.
  • Portability: An application and all its dependencies are bundled into a single container which can be shipped around. The container is independent from the host version of the Linux kernel, host Linux distribution and deployment model. A container can be shipped to any machine which runs Docker and be executed without any compatibility issues.
  • Version control and component reuse: Docker provides a version control system which allows you to inspect differences between versions and roll-back to a previous version. Containers can reuse components which makes them more lightweight.
  • Sharing: You can share your Docker images via a public repository or using your own.
  • Lightweight: Regular Docker images are quite small to provide rapid delivery and to reduce the time needed to deploy new application containers. A Docker container spins up in a few seconds, only a fraction of the time required to boot a VM.
  • And many more

Use Cases

  • Continuous Deployment: You can create a continuous deployment pipeline which pushes a Docker image to your Docker registry and which in turn updates all your running services easily to the new version.
  • Scalable applications: With Docker it’s easier and faster to scale your applications, as scaling means to add new instances to your application. Of course the software inside your container needs to support horizontal scaling, for example by implementing microservice architecture.
  • Testing: Working with Docker you can setup a fast and easy to use test environment for your developers where they can run their tests. No need to start virtual machines or even ask the operations team to push the software to the testing environment.

Getting started

The first step to getting started with Docker is obviously to install Docker. Find your OS in the installation section of the Docker documentation and have fun!

We’re hiring!

Looking for a change? We’re DevOps Engineers experienced with NodeJS, Git, Jenkins Puppet and of course Docker. Apply now!

Dockerize your project

If you want to get started implementing a Docker-based architecture in your project have a look at our website, drop us an email or call +49 721 619 021-0.

We offer consulting and solutions tailored to your needs. For more information on Docker we invite you to join our Meetup-group in Karlsruhe, where we organize events, talks and get-togethers. For a comparison of operating systems that support Docker read our dedicated article.

comments powered by Disqus