Skip to main content

Commands used in Dockefile - Part4

  Docker is an opensource tool used for virtualization and deliver software in the form of packages called Containers. It is one of the most important tools used in networking domain.  Dockerfile  is a template for building the image which contains commands needed to package the software. In this post, I am going to explain the commands ADD & COPY used in  Dockerfile .   ADD Command:   ADD command is used to copy files, directories or files from remote URLS to destination path in the image. The source paths can contain wildcards.   If the destination has relative path, it is relative to the Working directory of the image. Note that source path is always relative to the Docker build context.   ADD command will not support authentication. So, if there are any protected files to be added in  Dockerfile  building, use other tools like curl or  wget   Dockerfile  copying Single & Multiple files, directory using ADD inst...

Introduction to Docker Containers and Virtual Machines

What is a Virtual Machine? 
Virtual Machine is nothing but emulation of the hardware server. It uses the system physical hardware and emulates the environment on which the user can run applications. Virtual machines are mainly used in cloud computing to provide isolation and resource control. It loads a full OS and has own memory management to run applications in a secure & efficient manner. Virtual machines also ensure high availability. 

What is a Docker? 
Docker is nothing but an open source project that offers a software solution known as containers. Container is a small stand-alone & lightweight executable software code that has everything included for running it. Containers are scalable. They are safer to use and deploy.  Also, as containers are platform independent, Docker can run across both the Windows-based operating system and the Linux operating system. Docker helps in running microservices applications in distributed architecture. 

Understanding Virtual Machines: 
The architecture of Virtual Machines looks like below. Let’s explore what each layer does in terms of functionality. 
 
Infrastructure: 
The infrastructure can be a laptop or server in a data center. This server may be provided by providers like Amazon Cloud, Digital Ocean etc. 

Host Operating System: 
On the server or laptop, an operating system like Windows or Linux will be running. This operating system is called as Host Operating System 

Hypervisor: 
Hypervisor is the software that takes care of managing virtual machines launched on the Host Operating System. There are a lot of hypervisors available in the market. Some of them are HyperKit for MacOS, Hyper-V for Windows, and KVM for Linux. Hypervisors that can be used for any operating system include the Virtual box by Oracle and VMWare. 

Guest Operating System: 
Suppose let us assume that you want to run 3 applications on your server in an isolated environment. Then you will need 3 guest operating systems that are controlled by Hypervisor. Generally, each operating system size will be of 700MB. So, these three different guest operating systems occupy almost 2.1 GB. Furthermore, each guest OS needs to have its own CPU and memory resources. 

Binaries and Libraries: 
To run an application on guest OS, you need to have libraries and binary files needed by the application. For example, to run Ruby you need to install gems. Similarly, to connect to PostgreSQL, you need to have libpq-dev library on your machine having the guest OS. 

Applications: 
This application contains the source code to accomplish the required task. To run each application in an isolated environment, keep each one of them in the separate guest OS. 

Understanding Dockers: 
 
Infrastructure: 
The infrastructure can be a laptop or server in a data center. This server may be provided by providers like Amazon Cloud, Digital Ocean etc. 

Host Operating System: 
On the server or laptop, an operating system like Windows or Linux will be running. This operating system is called as Host Operating System. Dockers support Windows, Mac and major distributions of Linux OS. 

Docker Daemon: 
It is the service that runs in the background and is similar to Hypervisor in Virtual Machines. This takes care of managing and interacting with Docker containers. 

Binaries and Libraries: 
For running applications, binaries and libraries are needed. But in dockers, these are built into special packages called Docker Images. Docker daemon is the entity that runs these images. 

Applications: 
Each application will be placed in a separate docker image and these images are managed by Docker daemon. Each application has its complete isolation.  

Docker Architecture: 
Docker follows client-server architecture. It consists of four parts. They are: 
  
1) Docker Client: It is a component that interacts with containers by using the user interface for dockers. 
2) Docker Objects: It is a key component of docker consisting of owned containers and images. These images are read-only and can be used to create new containers. 
3) Docker Daemon: A background process that receives commands and passes them to containers using the command line. 
4) Docker Registry: Docker registry is the place where the container images are stored and retrieved. It is also called as Docker Hub. 
Real-World Use cases for Virtual Machines & Dockers: 
Real-World Use case for Virtual Machines: 
Starling bank, a digital bank is built in one year on VM provided by the Amazon Web Services. Using virtual machines provides greater efficiency and reduces the cost involved in using their own server by using virtual machines. 

Real-World Use case for Dockers: 
PayPal uses Docker for its infrastructure to reduce infrastructure costs and for enterprise security. It uses both Virtual Machines and Dockers to reduce the number of Virtual Machines needed to run their applications. 
Docker can be used to package application code and its dependencies. Thus, it brings portability in the software development cycle by sharing the same container among development, testing, and IT teams. 

Advantages of Virtual Machines: 
1) Virtual Machines are easy to access and simple to use. Docker has a complex ecosystem and has tools provided by Docker & third-party providers. 

2) Once you have created and Virtual Machine, you can run containers in it. So Virtual Machines and Dockers are not mutually exclusive. They both can co-exist alongside each other. 

Advantages of Docker Containers: 
1) Docker containers are process isolated and there is no need for Hypervisor. They are lightweight and occupies fewer resources when compared with virtual machines. 
2) Docker is very fast than Virtual Machines and takes only a few seconds to startup Docker container from a container image 
3) Containers can be shared across multiple teams and bring portability into the lifecycle of Software development.  

Conclusion: 
Nowadays Docker is getting popular especially in the domain of DevOps and being used in my corporations. Virtual Machines provide high flexibility whereas Dockers main focus is on the application and their dependencies. Both Virtual Machine and Dockers provides an equal amount of security. Dockers provide speed and great efficiency. In practical situations, both Virtual Machines and Docker Containers are used together to produce great efficiency, speed, and performance by leveraging the benefits of both Virtual Machines as well as Dockers. 

Comments

Popular posts from this blog

Commands used in Dockefile - Part4

  Docker is an opensource tool used for virtualization and deliver software in the form of packages called Containers. It is one of the most important tools used in networking domain.  Dockerfile  is a template for building the image which contains commands needed to package the software. In this post, I am going to explain the commands ADD & COPY used in  Dockerfile .   ADD Command:   ADD command is used to copy files, directories or files from remote URLS to destination path in the image. The source paths can contain wildcards.   If the destination has relative path, it is relative to the Working directory of the image. Note that source path is always relative to the Docker build context.   ADD command will not support authentication. So, if there are any protected files to be added in  Dockerfile  building, use other tools like curl or  wget   Dockerfile  copying Single & Multiple files, directory using ADD inst...

Commands used in Dockerfile - Part3

  Docker is an opensource tool used for virtualization and deliver software in the form of packages called Containers. It is one of the most important tools used in networking domain.  Dockerfile  is a template for building the image which contains commands needed to package the software. In this post, I am going to explain the commands WORKDIR & HEALTHCHECK used in  Dockerfile .   WORKDIR Command:   WORKDIR command is used to set the directory of the image on which the commands like RUN, COPY, ADD, ENTRYPOINT, CMD operates.   The command usage is WORKDIR < Path_To_Dir >. If the directory not exists, it will be created. If the relative path is given to WORKDIR, that path will be relative to the previous WORKDIR command’s path.    In Ubuntu, by default the WORKDIR will be  / . Please find the below sample  Dockerfile  to get clear picture of WORKDIR command:   FROM  ubuntu: 16.04   WORKDIR  /root ...

Vyos - An Open Source Network Operating System

What is  a  Network Operating System?   Networking Operating System (NOS) is an O perating system  that  has the capability to  support workstations, database sharing, application sharing, file ,  and printer access sharing among multiple computers in a network. In general ,  NOS is a specialized operating system used for devices like router, switch or firewall. Features of Networking Operating System:   NOS has the following features: Basic features like protocol support, processor support, hardware detection and multiprocessing support for applications Authentication, access control, authorization ,  and restriction facilities are supported to provide security Provides file service, web service, printing and replication Has Naming and Directory Management services Has  the provision  for user management and remote access & system management Also has internetworking features like routing and ...