DEV Community

murugan
murugan

Posted on

Docker Basic

Docker

Docker is a platform used to containerize our software, using which we can easily build our applications and package them, with the dependencies required, into containers, and further these containers are easily shipped to run on other machines.

In simple words, Docker is a software containerization platform, meaning you can build your application, package them along with their dependencies into a container and then these containers can be easily shipped to run on other machines.

For example: Lets consider a linux based application which has been written both in Ruby and Python. This application requires a specific version of linux, Ruby and Python. In order to avoid any version conflicts on user’s end, a linux docker container can be created with the required versions of Ruby and Python installed along with the application. Now the end users can use the application easily by running this container without worrying about the dependencies or any version conflicts.

Docker is an open-source centralized platform designed to create, deploy, and run applications. Docker uses container on the host's operating system to run applications. It allows applications to use the same Linux kernel as a system on the host computer, rather than creating a whole virtual operating system. Containers ensure that our application works in any environment like development, test, or production.

Docker includes components such as Docker client, Docker server, Docker machine, Docker hub, Docker composes, etc.

Docker simplifies the DevOps Methodology by allowing developers to create templates called ‘images’ using which we can create lightweight virtual machines called ‘containers.’ Docker makes things easier for software developers giving them the capability to automate infrastructure, isolate applications, maintain consistency, and improve resource utilization.

Docker is a containerization platform that packages your application and all its dependencies together in the form of a docker container to ensure that your application works seamlessly in any environment.

Virtualization

Virtualization is the technique of importing a Guest operating system on top of a Host operating system. This technique was a revelation at the beginning because it allowed developers to run multiple operating systems in different virtual machines all running on the same host. This eliminated the need for extra hardware resource. The advantages of Virtual Machines or Virtualization are:
1.Multiple operating systems can run on the same machine
2.Maintenance and Recovery were easy in case of failure conditions
3.Total cost of ownership was also less due to the reduced need for infrastructure

Containerization

Containerization is the technique of bringing virtualization to the operating system level. While Virtualization brings abstraction to the hardware, Containerization brings abstraction to the operating system. Do note that Containerization is also a type of Virtualization. Containerization is however more efficient because there is no guest OS here and utilizes a host’s operating system, share relevant libraries & resources as and when needed unlike virtual machines. Application specific binaries and libraries of containers run on the host kernel, which makes processing and execution very fast. Even booting-up a container takes only a fraction of a second. Because all the containers share, host operating system and holds only the application related binaries & libraries. They are lightweight and faster than Virtual Machines.

Advantages of Containerization over Virtualization:

1.Containers on the same OS kernel are lighter and smaller
2.Better resource utilization compared to VMs
3.Boot-up process is short and takes few seconds

Docker Containers

Docker containers are the lightweight alternatives of the virtual machine. It allows developers to package up the application with all its libraries and dependencies, and ship it as a single package. The advantage of using a docker container is that you don't need to allocate any RAM and disk space for the applications. It automatically generates storage and space according to the application requirement.

It is basically the instance of an image. Multiple containers can exist for a single image.

Docker Containers are the ready applications created from Docker Images. Or you can say they are running instances of the Images and they hold the entire package needed to run the application.

Docker Images

Images are nothing but a read-only binary template that can build containers.
Docker Image can be compared to a template which is used to create Docker Containers.They are the building blocks of a Docker Container. These Docker Images are created using the build command. These Read only templates are used for creating containers by using the run command.

Virtual Machine

A virtual machine is a software that allows us to install and use other operating systems (Windows, Linux, and Debian) simultaneously on our machine. The operating system in which virtual machine runs are called virtualized operating systems. These virtualized operating systems can run programs and preforms tasks that we perform in a real operating system.

Containers Vs. Virtual Machine

Containers Virtual Machine
Integration in a container is faster and cheap. Integration in virtual is slow and costly.
No wastage of memory. Wastage of memory.
It uses the same kernel, but different distribution. It uses multiple independent operating systems.

Why Docker:

1.Docker allows us to easily install and run software without worrying about setup or dependencies.
2.Developers use Docker to eliminate machine problems, i.e. "but code is worked on my laptop." when working on code together with co-workers.
3.Operators use Docker to run and manage apps in isolated containers for better compute density.
4.Enterprises use Docker to securely built agile software delivery pipelines to ship new application features faster and more securely.
5.Since docker is not only used for the deployment, but it is also a great platform for development, that's why we can efficiently increase our customer's satisfaction.

Dockerfile, Docker Image And Docker Container:

1.A Docker Image is created by the sequence of commands written in a file called as Dockerfile.
2.When this Dockerfile is executed using a docker command it results into a Docker Image with a name.
3.When this Image is executed by “docker run” command it will by itself start whatever application or service it must start on its execution.

Docker Compose:

Docker Compose is basically used to run multiple Docker Containers as a single server. Let me give you an example:

Suppose if I have an application which requires WordPress, Maria DB and PHP MyAdmin. I can create one file which would start both the containers as a service without the need to start each one separately. It is really useful especially if you have a microservice architecture.

Docker daemon:

A daemon creates, runs, and monitors containers, along with building and storing images.

Docker Registry

Docker Registry is where the Docker Images are stored. The Registry can be either a user’s local repository or a public repository like a Docker Hub allowing multiple users to collaborate in building an application. Even with multiple teams within the same organization can exchange or share containers by uploading them to the Docker Hub, which is a cloud repository similar to GitHub.

References

Top comments (0)