Containers vs Virtual machine

Кирилл Карпенок
3 min readSep 5, 2021

What’s the difference between them. How use them as part of a pet project or just make your hands dirty?

Look below.

Virtual machines commonly shortened to VM’s is the same thing as your computer at work office whenever it is. VM “borrows” from a physical host computer the resources, like CPU, memory, creates the image, simply file.

This VM behaves like the real computer, it is partitioned from the rest of the system — which gives you a nice isolated environment. The software inside a VM can’t interfere with the host computer’s primary OS.

When to use VM’s. Let’s dive further into the topic, describing both sides of the coin.

Pros of using VMs:

As said above key feature is isolation, you can run buggy code inside this environment or simply untrusted software, that needs to be tested.

Snapshots. You can take “snapshots” of your virtual machine, capturing the entire machine state (disk, memory, etc.), make changes to your machine, and then restore to an earlier state. This is useful for testing out potentially destructive actions, among other things.

Cons:

Slow, slow, and one more time slow. VMs are relatively slow and run slower than a full physical computer.

Running multiple virtual machines on one physical machine can result in unstable performance if infrastructure requirements are not met.

Containers.

Works the same as VM, in a sense of running isolated applications on a single platform. VMs virtualize the hardware layer to create a “computer,” containers package up just a single app along with its dependencies.

Virtual machines are often managed by a hypervisor, whereas container systems provide shared operating system services from the underlying host and isolate the applications using virtual-memory hardware.

A hypervisor is just software that creates and runs virtual machines. Allows you to run multiple operating systems in VMs, but containers are only able to run a single type of operating system.

Containers boot faster, maximize server resources, and make the process of delivering applications much easier.

Because containers include only the binaries, libraries, and other required dependencies, and the application. This is called an image — a code-based file that includes all libraries and dependencies.

The performance boost comes from the fact that, unlike VMs which run an entire copy of the operating system, containers share the Linux kernel with the host. However, note that if you are running Linux containers on Windows/macOS a Linux VM will need to be active as a middle layer between the two.

Containers are a handy and fast solution to some problems. Better development, “dependency hell” and etc. So, read these benefits and then decide when to use them.

  • It takes seconds to start the container. Greater efficiency, containers allow applications to be more rapidly deployed, patched, or scaled.
  • Boost the development, because instill on DevOps or CI/CD practices.
  • Also deployment. In a matter of seconds(or minutes), containers can be deployed easily to multiple different OS and hardware platforms.

What to choose?

Just choose the applicable software like VMware or VirtualBox then install the needed OS and everything seems to complete.

For containerization just choose Docker. Seems to be a nice choice.

In conclusion, for pet projects and just for work skills consider choosing Docker and learn some info about Kubernetes(read the documentation bro). Everything should be delivered as fast as it is, no matter is it your workplace or you are doing the Sunday pet-project — docker solves a lot of problems.

— — —

Useful links:

--

--