Learn about Docker and its Main Components

0
1322
learn-about-docker

learn-about-docker
Docker is an open source project created to help developers easily package their applications in containers. By using containers, developers are able to create applications that are separate from their infrastructure which reduces the software development cycle. Docker helps developers overcome challenges in dependency management, application scaling and partial updates of applications. When using Docker you divide your application into small fully functional components and package each component with all dependencies. Therefore, Docker provides you a platform to help you test, ship and deploy your applications fast.

Docker is an excellent choice for three types of developers:

  • Developers who want their applications deployed on many different systems.
  • System administrators who need an easy way to install applications on all their systems
  • Users or system administrators who need to use software not available from their Linux package manager. For example, you are able to run Ubuntu packages on Fedora.

Main components of Docker
There are four key components of Docker that you need to understand before you can use Docker in your development. These are the client and server, images, containers, and registries.

Docker client and server
Docker runs in a client and server architecture. The client communicates to the daemon which will build, run, and distribute your containers. The client and the daemon can run on the same host or run on different hosts and communicate through sockets or a RESTful API. As a developer, you will use the Docker client as your primary interface which is exposed as the docker binary. You issue commands to the client which are then sent to the daemon. Using a client is the only way to interact with the daemon.

Docker images
A Docker image is a read only blueprint containing information that will be used to create a Docker container. For example, you can create an image of a Linux operating system, your application and a web server. As a developer you can create your own images or use images that have been developed by others. Images are uploaded to the Docker hub (https://hub.docker.com) from where you can search and download the image for your use. You can modify an image to create other images. The definition of an image is contained in a text file with a structured syntax referred to as a Dockerfile. Dockerfiles offer the developer several advantages

  • When you use Dockerfiles there is predictability because the possibility of human error in the image creation process is eliminated
  • With Dockerfiles, versioning becomes easy because you commit the Dockerfiles to version control to keep track of changes and correct errors
  • Creating images using Dockerfiles is flexible because you can override default options. This way you only provide options needed.
  • When sharing images Dockerfiles provide accountability because others are able to inspect the process of creating the image.

Docker containers
While a Docker image is a blueprint, a container is the running instance of the image. We can look at a container as a run time object. Containers provide you with a lightweight and platform independent way of running your applications. Containers can be started, stopped, moved or deleted via the command line interface or the Docker API. Before any container can be run, you need to provide configuration options of the network and the environment where it will run. Every container is isolated but access to resources on another host or container can be allowed. Access to databases can also be given to an isolated container.

Docker registries
A Docker registry is a repository of images. Docker repositories can be public or private. Docker hub (https://hub.docker.com) is a public registry where you can search and download images. Google cloud platform (https://cloud.google.com/container-registry/) and Quay (https://quay.io) are other registries that have public and private features. Registries enable distribution of Docker components.

Advantages of using Docker
As a developer, Docker gives you several advantages:

  • Docker makes code testing and deployment in production environments easy and very fast.
  • Docker makes application assembly from components quick and reduces conflicts that may arise when shipping code. For example, when using Docker you are able to run multiple versions of the same application in different containers on a single host.
  • Docker is very simple to use. To start using Docker you only need an operating system like Windows, Linux or OS X directly or virtually running a compatible Linux kernel and a Docker binary.
  • Docker containers run on most environments. They can be deployed on desktops, physical or virtual servers, data center or in the cloud. You are able to run the same container in all the different environments without any modifications.
  • In most cases, containers require a very short time to be launched.

Differences between containers and virtual machines
A virtual machine (VM) contains the application, guest operating system and required libraries which could be several gigabytes while a container has the application and its dependencies but the kernel of the operating system is shared with other containers. Launching a virtual machine takes several minutes while launching a Docker container just takes a few seconds.

Conclusion
In this tutorial, we introduced Docker, which is a platform for packaging applications so that they can run in different environments without modification. We discussed four important components of Docker and how they help a developer. We discussed advantages of Docker and how it differs from virtual machines.

LEAVE A REPLY

Please enter your comment!
Please enter your name here