Docker is one of the most exciting technologies of this decade. However, despite its surging popularity, many developers are not clear about it. In this post, we will try to understand the basics of Docker. What makes it so popular? And how can you start with it?

This is part of our Docker Step-by-Step Learning series of posts.

If you are more of a video person, check out the Basics of Docker on my You-tube channel

https://youtu.be/Pac4LMRawos

What is Docker?

Docker is a container technology. It basically helps building and deploying new applications faster. Docker containers wrap up the software and its dependencies into a standardized unit.

What does this mean for a developer?

It means that the code of your application, run-time environment, system tools and libraries are all bundled together. This bundle is then deployed into staging and production environments. The concept of bundling basically guarantees that the application will always run the same no matter where it is deployed.

This is an extremely powerful concept. It is also the main reason for Docker’s popularity in the industry

A Dose of History

Docker was released in 2013 as an open-source project. The company behind it was called dotCloud. However, the idea behind containers was not new. In fact, the concept of Linux containers had been around from 2008 itself.

Docker, however, made it popular. This was partly because of the increased portability that Docker brought to the table. Docker allowed developers to write an application in any language and then easily move it from a developer machine to a test machine and all the way to a production server. Due to this level of portability, Docker became an overnight success.

According to a figure, almost 10K developers admitted trying Docker out almost 1 month after its tutorial launch in 2013.

In fact, within a few months, companies such as Red Hat and Amazon added commercial support for Docker. According to an estimate, Docker Engine software has been downloaded more than 100 million times.

It is quite evident that Docker is here to stay. Its adoption across large enterprises has increased dramatically over the last few years. Some of the most critical applications in the world today are utilizing Docker containers.

What makes Docker so special?

To really understand what makes Docker special, we need to first understand the issue it is trying to solve.

Before Docker came around, the common way for developers to deploy their applications was using virtual machines. If one particular server had to host multiple applications, each application would run in its own virtual machine. It would look something like below:

basics of docker virtual machine

If you see above, each virtual machine is running its own guest operating system. The application and its dependencies reside on that guest OS. Usually in this setup, applications get a lot more resources than they actually need. In other words, there is a waste of resources.

However, Docker takes a different approach to this. See below:

basics of docker

You can already spot the difference. Here, we have something known as Docker software or simply Docker running on the infrastructure. It controls all the containers. Each container has application and dependencies bundled together.

But here’s the big difference.

In Docker, every container shares the kernel of the actual host with other containers. In other words, containers provide what could be coined as OS-level virtualization. Each container runs in its own user space on top of the operating system. Multiple containers can run on one host machine having their own user spaces.

This makes the containers super-efficient and lightweight. Developers don’t have to worry about OS setups on each of these containers. They can just focus on their application and its dependencies, package them in the required container and deploy it.

Setting up Docker

How can you start working with Docker?

Docker is now available for Windows, Mac and Linux OS. You can basically follow the guidelines for each of the options in this installation guide.

However, there’s a small catch. When we talk about Docker containers, we are talking about Linux containers. Docker runs natively on Linux.

So what does this mean?

This means that on Windows and Mac, running Docker basically involves a workaround.

When you install Docker on Windows, under the hood Docker uses the hypervisor layer of Windows and then installs a minimal Alpine Linux distribution. This Alpine Linux hosts the Docker engine. This is as close to native Docker you can get on Windows right now.

Similarly on Mac, it utilizes the new hypervisor framework based on the open source project xyhyve. Then similar to Windows, Alpine Linux distro is installed on xhyve virtual machine.

On Linux, Docker runs natively. And depending on what you are looking for, this can be an advantage. Even though Docker for Windows and Mac has become really stable, there is still a slight overhead because of the hypervisor layer. If you have an option to use Linux, it would be the best platform to work with Docker.

Important Docker Terms

Some important terms associated with Docker are as follows:

Docker Daemon listens for Docker API requests and manages the Docker objects such as images, containers. You can think of it like a server that processes incoming requests based on certain conditions.

Docker Client is the interface through which developers or users interact with Docker Daemon. The commands issued by the user to the Docker Client are communicated to the daemon and are executed. Usually, developers use a CLI or Command Line Interface to issue commands.

Docker Registry is the place to store images. Docker Hub is a public registry. Anybody working with Docker can use it. Even Docker is pre-configured to use the public registry by default. We can consider Docker Hub as similar to Github. One can also have private registries where developers belonging to a particular group or company can share images.

Images are read-only templates or blueprints to create Docker containers. Most of the time, an image uses another base image and customizes it to create a new image. For example, a developer can pick a Ubuntu base image and install a web-server and a web application on top of it to create a new image. This new image can then be used to spawn a Docker container.

Containers are basically a running instance of the image. We can create hundreds or thousands of containers using a single image. These containers can be started, stopped, moved around using the Docker Client or the CLI.

Docker Client-Server Architecture

As we can judge by now, Docker has a client-server architecture. When we install Docker, we basically get two things. They are the Docker Client and Docker Daemon.

Below is a representation of the whole process:

docker basics client server setup

As the diagram illustrates, the Docker Client forwards the commands issued by the user. The Docker Daemon handles the commands. The daemon can then pull the image from the registry if it does not have it already and create a container using that image. In case the daemon finds the image in its own storage, it need not go to the registry.

Conclusion

To conclude, we have now looked at Docker and understood the basic concepts behind it. We also have looked at what differentiates Docker from Virtual Machine approach and also explored the most important terminologies.

Docker is definitely a very exciting technology and it is going to grow in the coming years. I have been working with Docker containers for some time now in production environment and have found it incredibly useful.

What do you think about it and have you got a chance to use Docker? Sound off your views in the comments section below.

Categories: BlogDocker

Saurabh Dashora

Saurabh is a Software Architect with over 12 years of experience. He has worked on large-scale distributed systems across various domains and organizations. He is also a passionate Technical Writer and loves sharing knowledge in the community.

2 Comments

TW · December 21, 2021 at 7:05 pm

Great illustrations and description for someone new to docker.

    Saurabh Dashora · December 28, 2021 at 11:49 am

    Thanks for the great feedback!

Leave a Reply

Your email address will not be published. Required fields are marked *