After creating a product, you may face certain problems when presenting it to customers. Some elements may differ on other platforms: OS, configs, external libraries. Also, different methods are used to create the whole infrastructure. In this topic, we'll look at Docker, one of the most popular solutions to ease up the process of delivering an application.
What is Docker?
Docker is a technology that provides virtualization with hundreds or even thousands of isolated and independent containers on the same operating system.
While each container has its own operating system, they share the host's kernel rather than having their own.
Docker runs an application with a chosen operating system and version in isolation from other applications. It utilizes the container structure and the images downloaded from the registry, for example, the most famous is Docker Hub. In this case, it eliminates the dependency problems and makes containers with applications self-contained.
Similar to how a virtual machine virtualizes server hardware, containers virtualize a server operating system. Thanks to this operating system, we can install the necessary programs, and run our applications in this container. Docker provides us with simple commands to do it.
Docker architecture
Docker is a system that emerged with the support of the Linux kernel, so it runs on the Linux operating system. So how can Docker be used on both Windows and macOS?
Docker has a client-server architecture. It has a background daemon process and a CLI interface to work with containers. On Linux, both the daemon and CLI can run directly on the host's OS. In Windows and macOS, the Docker CLI runs in the host operating system, and the daemon runs on the virtual machine with the Linux OS because the daemon needs a Linux OS kernel.
The heart of the Docker –the daemon process– works with three types of Docker software components:
Client
Objects
Registry
Now, let's review them one by one.
Client
Docker has the client-server architecture. So the client runs on your own host, and the server side is the host where the Docker daemon runs. The Docker client can communicate with more than one daemon.
Also, the client offers us a command-line interface, allowing us to create, run, and stop application commands.
Registry
The Docker registry contains Docker repositories that can contain more Docker images.
Thanks to the Docker registry, you can store and upload images. For example, Docker Hub is a public registry that anyone can use. In short, images are kept in the Docker Registry.
You can even run your own private registry on this platform. It serves in Docker Hub Cloud, there is also a Private Registry service for those who want to keep the images in their private cloud.
Objects
You can create new Docker images by combining such objects as:
Image
Container
Network
Volume etc.
We have already mentioned containers, and now we'll talk shortly about images. We'll take a look at the other objects in the upcoming topics.
Each container is an image with a readable/writable layer on top of a bunch of read-only layers. A Docker image is a collection of files and applications that will be installed and launched in containers. You can visit Docker Hub to review Docker image files.
As you can see, there are many images in the Hub. In fact, there is a type of file that describes the contents and descriptions of the built images named Dockerfile. We will refer to this file in the next topics.
Docker pros and cons
So why Docker? Now let's summarize the advantages that docker provides us with.
It makes it easy for you to build scalable data processing systems and conveniently manage platforms for your developers.
There is no need to set up a new environment to use it.
It supports different operating systems, such as Windows, Linux, macOS.
It has a large community. Finding answers to your questions is pretty easy.
It can be integrated with the Docker cloud services.
Now let's summarize the disadvantages of the docker.
To create your images, you need to learn the syntax of Dockerfiles.
To launch a lot of containers, you need to know how to work with the orchestration systems.
It gives a slight overhead relatively to running on the bare OS.
There are some performance issues in non-native environments.
How to install Docker?
Installation on various OSs may differ, so we're providing you with links to official documentation where you can find all the necessary details:
There is an option to try the docker online too. Play with Docker is a site that allows users to run Docker commands.
You can build and run Docker containers and even create clusters in Docker Swarm mode and access a free Linux Virtual Machine in your browser. Thanks to this site, you can try Docker commands without installation.
Conclusion
The most important things to remember about Docker:
It is not a hardware virtualization technology
It uses a layered file structure
It is a container management tool
It has a fairly large ecosystem
It supports multiple platforms
Docker is a technology that provides virtualization with independent containers on the same operating system. In addition, Docker takes the hassle out of running applications in different environments.
Read more on this topic in Bridging the Gap by Understanding DevOps on Hyperskill Blog.