A gentle introduction to Docker and containers
Photo by frank mckenna on Unsplash
A gentle introduction to Docker and containers
There are plenty of great resources to learn how Docker works, what are containers and how to benefit from them, but it's often focused on either business side or on developers/administrators.
I would like to take a different approach and provide an introduction to both, business and technically-minded readers.
At the end of reading this blog you will
-
know how Docker works on a high level
-
understand benefits of using containerized workloads
-
have a hands-on experience with Docker
-
learn where to find more information and training resources
This article is also published as slide deck on slides.com, feel free to use the presentation for learning or maybe showing to your colleagues or team what Docker and containers are all about.
In this section we talk about what problems Docker solves. How it helped real companies with their digital transformation and we will look into benefits that Docker and containerized workloads bring.
World before Docker and containerized workloads
If you are long enough in IT and software development business, either as administrator, developer or architect, you will be able to relate to the below image. Before Docker and idea of packaging software into containers, all workloads required their own set of dependencies (often conflicting with other components).
On the other hand, you might also remember times before virtualization, where provisioning meant actually acquiring expensive physical servers, waiting often for months. Virtualization solved this problem to some degree, but virtual machines were still slow to boot and wasted resources.
Behold, the matrix of Hell!
The matrix from hell. Source: everywhere on internet, I couldn't find original source.
Benefits of Docker and containers
Matrix of hell becomes matrix of containers. Docker helps us ΓÇ£packageΓÇ¥ each software component as a standardized container image and run it with a very high degree of portability in a repeatable and reliable fashion.
The matrix from hell. Source: everywhere on internet, I couldn't find original source.
I find that main benefits of using Docker and containerized workloads are:
This is not all, there are other important aspects where containers help:
-
Standardization and Productivity
-
Maintainability
-
Simplicity enabled by immutability
-
Rapid Deployment
-
Multi-Cloud Platforms
-
Workloads isolation
Docker success stories
Let's look at some of the early adopters of Docker and their success stories. Those companies were able to improve their processes often to a dramatic degree!
Information source: http://techgenix.com/containers-success-stories/
ADP
Lessons from ADP:
Increased developers productivity due to:
-
faster feedback during development cycle
-
standardized development environments
PayPal
Lessons from PayPal
-
Enable development Teams transition to containers by having a dedicated ΓÇ£platformΓÇ¥ team to help and guide containerization
-
By decoupling Dev and Ops concerns developers can be more efficient and operations can upgrade/manage systems easier
MetLife
Lessons from MetLife
-
Enable microservices-oriented architecture and gradual modernization of legacy applications
-
Take advantage of modern cloud offerings to improve development speed and scale
Continue reading if you are interested in learning about Docker architecture and how containers work.
Docker Architecture
Let's introduce a few definitions:
Images are blueprints of our application which describe containers content and behavior. Images are immutable with a thin writable layer, this characteristics is one of the most appealing features of containerized workloads.
Containers are created based on Docker images and represent the actual instance of an app/service/etc. If you come from OOP programming background you can think about containers as instances of classes and images as classes themselves.
Docker Daemon is a Linux background service running on Docker host machine and manages life cycle of Docker containers (creating, running, deleting, etc). In Linux terminology daemon is a process that runs in the operating system usually as a service.
Docker Client is Docker's command line interface (CLI) and facilitates communication between the user and docker daemon using REST API calls. Docker CLI is not the only client, there are plenty of UI implementations such as Portainer of Kinematic.
Docker Hub or Docker Registry is simply a registry of Docker images. This registry can be public ( https://hub.docker.com/) or private hosted on public or private cloud.
Below graphic from docker.com shows how docker architecture works on a high level.
docs.docker.com
Docker flow
Typically using Docker revolves around consuming images from either public or private repositories and running containers. Another direction is to create Docker images based off of Dockerfile (other options are also available, for example using Ansible to create docker images).
Image Layers
As mentioned before, Docker images are immutable and are constructed by using layers (union file system on Linux). Each layer represents new image put on top of the previous one.
VM and Containers
It is worth point out that containers are not a replacement for virtual machines. Both have their uses and strength/weaknesses. In fact it is often beneficial to run containers on virtual machines for maximum flexibility.
The main difference is that containers share underlying OS resources directly without a need for a hypervisor.
Learning Resources
There is a lot of great learning resources, but I had most success using below 4:
-
KodeKloud free Docker for beginners course. Excellent FREE training from Mumshad Monnambeth.
-
Docker curriculum. If you prefer reading, this is comprehensive and in-depth resource.
-
Plularsight Courses from Nigel Poulton. If you happen to have Plularsight subscription or even want to try for free (10 days). Nigel is a great trainer and his Docker courses are one of the best I ever seen.
-
Official Docker documentation getting started. Last but not least, what is better than going directly to the source and exploring Docker home page.
Workshop and hands on labs
If you would like to play with Docker and containers, there is no need to install anything on your machine nor spin up infrastructure in public cloud providers! Below resources enable you to play with Docker directly in your browser
-
https://killercoda.com/loodse/courses/docker. Dedicated Docker workshops and hands on guided labs
-
https://labs.play-with-docker.com/. Interactive environment with Docker installed where you can explore and experiment for free. Environment is active for 4 hours)
Conclusion
This introduction to Docker and containerized workloads was intended to be just that, an introduction. We haven't talked about developer experience when developing software using containers, which will be a good subject for next blog and lots of other important topics. Most of the paragraphs were intentionally kept short.