Advantages of Docker Over Virtual Machines

The previous article gave us an overview of the docker and how it works. We discussed heterogeneous development environment, dockerfile, docker image, and code collaboration. In this article, we discuss issues with VMs and how docker helps in those issues.

About virtual machines

Heterogeneous development environment problems can be mitigated by sharing the same development environment with others. Virtual Machines (VMs) offer a solution. Software like VMware helps create VMs on a host machine using a hypervisor. For each VM, we need to manually:

– Install an operating system (OS)
– Allocate RAM from the host machine
– Allocate disk space for software installation

Hypervisor and Its Role

The hypervisor establishes communication with the hardware, enabling the creation and management of VMs. It abstracts the physical hardware so multiple VMs can share the same resources.

Issues with Virtual Machines

Despite their utility, VMs come with challenges:

1. Resource Allocation:

For example, if a host machine has 8 GB RAM and a VM is allocated 4 GB, only 4 GB remains for the host or other VMs. If a VM requires 6 GB RAM, it cannot be created due to insufficient resources.

2. Resource Wastage:

Once resources are allocated to a VM, they cannot be used by another process or VM, even if they are lying unused. Thus, we have a situation where resources may be lying unused, but we cannot use them, and thus, there is a waste of resources.

That means that once resources are allocated to a VM, they cannot be reallocated to other processes, even if they are unused.

3. Manual Setup:

Each VM requires a separate setup for OS, RAM, and disk space. These constraints limit the number of VMs that can be created and lead to inefficient resource usage.

Enter Docker

To address these challenges, Docker Inc. developed the Docker Ecosystem, which includes several tools and the Docker Engine.

Docker Working

Dockerfile specifies all dependencies that are needed to get an environment and using docker engine commands we create docker image. This image has all dependencies pre-bundled in it. This docker image is uploaded on dockerhub.

Any user can download this image and when this is installed on a machine using docker commands then all environment gets setup automatically in an isolated container.

As soon as the container finishes its task, it can be shut down manually or it can shut down automatically if designed like that. After the container shuts down, all host resources like RAM are released to the host machine. A container is something, that takes the help of the host machine OS to run and it remains isolated from the host machine.

  • Save

Docker vs. Virtual Machines

Resource Allocation

Docker containers dynamically request resources as needed, while VMs require fixed allocation.

OS Usage

Containers utilize the host OS kernel, whereas VMs require separate OS installation.

Scalability

Containers avoid resource wastage and can scale efficiently. VMs are limited by the number of blocked resources.

Conclusion

Docker excels in optimizing resource usage, scalability, OS usage and platform independence. Docker’s lightweight and efficient nature makes it a popular choice for modern development workflows.

Leave a Comment

Your email address will not be published. Required fields are marked *

Share via
Copy link
Powered by Social Snap