What is Docker and Why Should We Use It?

What is Docker and Why Should We Use It?

If you are involved in the IT industry world, then you have very likely heard about the container platform Docker. Docker can be considered as a new way of running software. It is able to revolutionize software development here and now.

This new technology lets development teams build, manage, and secure applications conveniently.

This post is the right place to start for those who want to take a look into Docker and containerization.

What is Docker about and why is it so popular?

Docker is a technical solution that was developed by Docker company under the Open Container Initiative. This company was formerly known as DotCloud.

This technology quickly helped the company raise its funds and opened directly new opportunities and chances to stay in the game. The users who work on a Linux base may run several containers and each container may hold a single app.

If dive more inside into the tech sense, we’ll see that when someone runs an application on an operating system, it runs on its userspace. And every operating system comes with a single instance of this user space.

According to Docker functionality, every container is able to offer one separate userspace. Containers let users have multiple instances of user spaces on a single OS. That’s why we can say that a container is just an isolated version of a user space.

Basic vocabulary: what are the main Docker constructs?

The environment of Docker involve the following points:

  1. An Engine is the core component that is responsible for running workloads in the form of a container. There are three variants to choose: the Community edition, the Enterprise edition, and the Experimental one.
  2. A Client that comes equipped with the Engine package in form of Docker binary. It connects to the locally installed Docker Engine by default.
  3. An Image is just like what an ISO image is for a virtual machine. The Docker image includes various layers stacked on top of one another. The first layer is the base image, the second one is the application layer, the third layer consists of any sort of updates.
  4. Repository and Registry. A Docker repository is a place where the Images, by default, go when you push one. This repository is contained within a Registry. The popular public Docker registry is Dockerhub.
  5. A Container is an isolated version of user space, starting with using a Docker image. It’s worth to note that in the Container, the PID is assigned to the command or service that it is supposed to run, unlike in Linux systems where the first PID is assigned to init or system. If that process is dead, then the container exits out.

To run a Docker environment at the basic level you will need two Docker components: Docker Engine and Image.

Docker and VMs: main differences

Docker differs from a VM and here are the main bullets:

  • In terms of size and resource consumption, Docker seems more lightweight than a virtual machine. That’s because a container is just the bare bones of an OS and it involves only the most basic stuff for its running.
  • Docker requires less time to spin up in contrast to a VM. Actually, it depends on the app that you’ll be hosting on a container. Typically, it’s just a couple of seconds.
  • A Docker container can run only one process. When that process stops out for some reason, the container expires, as well. This order can be modified of course (to run multiple processes), but doing that, you’ll lose the important concept of “loose coupling” your components. In this case, VMs look better.

The principles of Docker working

A Docker container leverages existing Kernel features while being on a Linux-based OS.

  • Name Space – that must not be confused with user spaces. The difference is essential. These namespaces are Network, PID, IPC, User, Mount, UTS, and they allow a Container to have its own view of Network, PID, hostname, and so on.
  • Control Groups (CGroups) that allow Containers to have a reserved/dedicated amount of resources assigned to them in the form of CPU and memory.

Docker also uses storage drivers such as AUFS, Overlay, DeviceMapper, BTRFS, and VFS.

How to create a Docker Image?

If there are no specific requirements, you may find and pull an image directly from the Docker hub that suits your needs. Do it with the Docker command line. The more “stars” an image has, the more reliable it is.

Sometimes users need to custom the image that’s not already available. In this case, they pull a base image and run a container from it. Then they do all the required modifications and commit it as an image.

What is a Dockerfile?

A Dockerfile is a plain text file aimed to visualize all your instructions to create an image. It is read one at a time, from left to right, from top to bottom.

Writing instructions, you’ ll definitely use such terms as run, command, environment, or from maintainer.

Two core things about Dockerfiles should be noted:

  1. The more run instructions you add, the more layers will be added to your image.
  2. One Dockerfile may include only one command. When you add multiple, the last one will overwrite others.

Docker in the real world: how do we use it?

Docker cannot be run merely as is just to handle your workloads (especially production workloads).

You need to have a scheduling and orchestration solution for a containerized environment. Some of the most popular container orchestration solutions involve Kubernetes from Google, Mesos Marathon from Apache, EC2 Container Service from AWS, Docker Swarm from Docker (mainly a host-based clustering solution rather than a container).

Which one to choose? In fact, it depends on your business and workload needs.

THE CLOUD
IS IN OUR DNA.

GET STARTED
2019-04-08T14:58:22+00:00