blog posts

Docker

What is Docker and what are its uses?

Docker is a software platform for building Container-based applications. Small, lightweight executable environments that share the operating system kernel but are also in an isolated environment. Although the concept of container has long been in the IT field, Docker was introduced as an open source project in 2013. In fact, Docker brought the container to life and became popular again. Software development shifted to the use of containers and microservices and later became known as cloud-native development. You may not know some of the concepts mentioned so far, but do not worry at all, because we will review all of them together until the end of the article, and in the end we will understand what Docker is and what its uses are.

What is the meaning of Container?

One of the goals of new software development systems is to keep applications in the same environment, but in isolation. In this way, their activities do not affect each other and work separately. Of course, this process can be complicated by the use of packages, libraries, and other software components.

One way to implement this technology is to use a virtual machine that keeps applications on the same hardware but completely separate. In this case, our components do not interfere with each other and competition for the use of hardware resources is minimized. But virtual machines also have problems. First of all, they are heavy software and require relatively powerful hardware. Each program also requires a separate operating system, which may be several gigabytes in size. And that they may be difficult to maintain and update.

In-depth review of Container with an example

Opposite is Container, which can be a good alternative to virtual machines. Container separates executable environments and shares the operating system kernel. They are usually in megabytes in size and use fewer resources than virtual machines. Also, unlike virtual machines, which require a relatively long time to run, containers run immediately.

When we compare the Container with a virtual machine, we are on the side of an account simulator. But what exactly are we simulating? To better understand the subject, it is better to use an example. Suppose you work for a company and you make your lunch at home every day and take it to the company in a container to enjoy. You no longer need to start cooking inside the company as it will probably take a lot of time. Container work is somewhat similar. You put your project (food) in the Container and take it wherever you like (for example, the company).

What is Docker?

Docker is an open source project that allows you to build Container or Container-based applications. Although Docker was originally built for Linux, it runs well on Windows and MacOS today. To build a program with Docker, we have to use different components. Now to better understand the concept of Docker, it is better to go to these components and examine them:

Dockerfile

Each Docker Container starts with a Docker file. Dockerfile is a text file that contains Docker Image instructions with a simple and understandable syntax (we will examine this concept a little later). This file contains very important information that can be used to set up Docker Image. It is essential. In fact, Dockerfile specifies what operating system is behind our Container, as well as which languages, local variables, network ports, etc. to use. And most importantly, specify what our Container is going to do after it is actually executed.

Docker image

In fact, when you have finished writing Dockerfile, you call a feature called Docker Build, which is responsible for creating an image based on the contents of your Dockerfile. Dockerfile contains a set of instructions for creating an image, while Docker Image is a portable file that contains a set of instructions that specify which software components the Container should run and how to run them. Most likely Dockerfile wants to download a number of files from different repositories (Repository) and here you have to specify which versions to download. Also, the created image is static, meaning that it is enough to create it once and you do not need to change it. As you can guess from their name, Image is an image of the main operating system.

Docker run

The Docker run feature is actually a command that launches the Container. We know that each Container is an instance of the Image and the nature of the Container is temporary. However, they can be stopped or restarted. Each image can have a large number of containers (as long as each has a unique name)

Docker Hub

Although creating containers is easy, you do not have to create a Container for each image from scratch. This is a SaaS repository for sharing and managing Containers. There you can find official images, which are usually open source. The general public also adds their projects to this Repository.

Docker Engine

It is the thinking brain and the core of it. A client / server technology that builds and executes containers. In fact, if someone is talking about Docker and does not mean the Docker Company or the Docker project, it means they are talking about the Docker Engine. This engine is available in two versions, Enterprise or Community. The Community version is open source and completely free, while the Enterprise version has a number of additional features and costs around $ 1,500 per node per year.

How does Docker work?

We’ve covered all of this to get to this section and understand what is  and how it works. Docker can be considered a virtual machine, but not in the way that virtual machines work. This service helps you to divide an environment into several sections and run a separate program in each section. To better understand the subject, consider Docker as a virtual machine for a moment, we know that virtual machines with Hypervisor perform simulation operations, but in Docker this layer is removed and we work directly with the operating system kernel. This greatitly increases the efficiency of the system.

Instead of installing multiple operating systems in one emulator, we install it once. Think of this process as installing regular software. Docker then creates independent environments called Containers, where each Container can contain different software packages. Now you can create different containers inside Docker and run your projects on each one independently.

Conclusion

Docker is an open source tool for designing and building applications using Container. Container helps the programmer to package his project with all its parts (such as libraries, affiliates, etc.). Thanks to this technique, the programmer is confident that his program can run on other systems without the need for special settings or peripherals. Think of the Docker as a virtual machine, except that it has a much higher efficiency.