DEV Community

Cover image for Docker – Need for Docker and Docker Terminologies
Ramya Perumal
Ramya Perumal

Posted on

Docker – Need for Docker and Docker Terminologies

Need for Docker

When more than one application runs on a single physical machine, all the applications have to share the machine's memory, CPU, and computational resources.

Suppose one application consumes more computational power. In that case, the other applications may become slow or even stop responding.

One solution is to run each application on a separate physical server. Although this provides better performance and isolation, the infrastructure cost and maintenance cost become very high.

To overcome this problem, the concept of Virtual Machines (VMs) was introduced.

In a virtual machine environment, each application runs on its own operating system while sharing a single physical machine.

Benefits of Virtual Machines

  • Reduced hardware cost.
  • Lower maintenance cost.
  • Better isolation between applications.
  • Multiple operating systems can run on a single physical machine.

A software component called a Hypervisor is responsible for virtualizing the physical machine and allowing multiple virtual machines to run on it.


Types of Hypervisors

There are two types of Hypervisors.

Type 1 Hypervisor

A Type 1 Hypervisor is installed directly on the physical machine (bare metal).

Type 2 Hypervisor

A Type 2 Hypervisor is installed on top of a host operating system.

We generally use Type 2 Hypervisors on personal computers. They allocate virtual resources to each virtual machine either manually or dynamically.


However, virtual machines still require a complete operating system for every application, which consumes a significant amount of memory and storage.

This means we are not fully utilizing the operating system resources for every application.

To overcome this limitation, Containers were introduced.

Containers include only the minimum libraries and dependencies required to run an application.

Benefits of Containers

  • Containers consume much less memory than virtual machines.
  • Containers start much faster.
  • Containers are lightweight.
  • Containers are portable.

An application is packaged as a Docker Image, which can be shared with any number of users and run consistently across different environments.


Docker Terminologies

For better understanding, let's compare Docker concepts with a kitchen.

Docker Concept Kitchen Analogy
Docker Engine The kitchen where everything happens.
Dockerfile The recipe that contains the ingredients and preparation steps.
Docker Image The finished dish prepared using the recipe.
Docker Container A serving (portion) of the finished dish.
Docker Registry A pantry that stores many dishes (images) with different tags.
Docker Daemon The chef who prepares the dish (image) by following the recipe (Dockerfile).

Installing Docker

Download and install Docker Desktop.

Once the installation is complete, Docker is ready to use.


List Images Available on the Local Machine

docker images
Enter fullscreen mode Exit fullscreen mode

This command lists all Docker images available on the local machine.


Pull an Image from Docker Hub

If the requested image is not available locally, Docker automatically downloads it from the Docker Registry.

docker pull hello-world
Enter fullscreen mode Exit fullscreen mode

If no tag (version) is specified, Docker downloads the latest version by default.

docker pull hello-world:latest
Enter fullscreen mode Exit fullscreen mode

To download a specific tagged version:

docker pull hello-world:nanoserver-ltsc2025
Enter fullscreen mode Exit fullscreen mode

Create a Container from an Image

docker run hello-world:latest
Enter fullscreen mode Exit fullscreen mode

List Containers

docker ps -a
Enter fullscreen mode Exit fullscreen mode

-a displays all containers, including exited containers.


Interview Questions

Question 1

What is a Virtual Machine (VM)?

Answer:

A Virtual Machine is a software emulation of a physical computer. It behaves like a separate computer with its own operating system.


Question 2

What does a Hypervisor do in virtualization?

Answer:

A Hypervisor allows multiple virtual machines to run on a single physical host by managing and allocating hardware resources.


Question 3

What are the advantages of using containers?

Answer:

  • Containers are lightweight.
  • Containers start much faster than virtual machines.
  • Containers are portable and can run consistently across different environments.
  • Containers package only the required dependencies.

Note:

Containers share the host operating system kernel. If the host kernel encounters a critical issue, all containers may be affected.

Virtual machines have separate operating systems. Therefore, if one virtual machine crashes, the others continue to run independently.


Question 4

Which type of Hypervisor runs directly on physical hardware?

Answer:

Type 1 Hypervisor.


Question 5

What is the difference between a Virtual Machine and a Container?

Answer:

  • Containers share the host operating system kernel.
  • Virtual machines run their own operating system on top of a Hypervisor.

Question 6

What is Docker primarily used for?

Answer:

Docker is primarily used to containerize applications, ensuring portability, consistency, and providing only the minimum required dependencies to run the application.

Top comments (0)