Published On: Mon, Apr 10th, 2017

The Difference Between Virtual Machines and Containers

Decoding Virtual Machines

Before we begin to understand the difference between virtual machines and containers, it is important to understand the definition of each. As the name implies, a virtual machine is nothing but an emulation of a physical computer system. It is usually a combination of hardware and software virtually put together to act like a physical computer system. There are two types of virtual machines – system virtual machines and process virtual machines.

System virtual machines replace real machines and provide all necessary functionality to execute an entire operating systems. A hypervisor is used in this case to allow multiple environments isolated from one another on a single physical machine. Process virtual machines are meant for execution of computer programs on platform independent environments.

What are containers?

Containers too, provide a virtual technology services to run applications through isolation. It basically is a stand-alone package that contains everything necessary to run, namely the piece of code, the runtime environment, necessary system tools, libraries, and any other such dependencies required for execution. The containerized software will run the same way irrespective of the underlying platform.

As you read it is easy to note that both virtual machines and containers operate in a similar manner and hence it is easy to get confused between the two. But there are differences between the two that are marked. Let’s take a look at these in order to be able to differentiate the two.

The differences

  1. A virtual machine virtualizes a physical machine, whereas a container virtualizes the operating system. Containers require the presence of an underlying operating system to run and provide isolation for the applications. But virtual machines come with their operating system to run.
  2. Basically, containers package the code and all necessary dependencies together at the app layer. Virtual machines are a virtual bundling of physical hardware put together to work as a single unit.
  3. Containers occupy less space and have a lower overhead as compared to virtual machines. Virtual machines are said to take up huge amounts of spaces to the tunes of tens of GBs as compared to that of containers that is usually in tens of MBs. This is definitely an advantage.
  4. Containers are also said to be more efficient and portable than virtual machines.
  5. Containers are faster and start up instantaneously, whereas virtual machines can take up time to boot.
  6. Multiple containers can run on a single machine and isolation between containers is provided. In a virtual machine, any communication is forced to go through the hardware or device drivers handling the hardware.
  7. All applications running in a container will share the underlying operating environment, whereas systems running as virtual machines can have different operating systems.

There are technologies that combine both approaches in the interest of getting the best of both worlds. Technology majors like Google and Facebook are said to be heavily investing in container technology. Even Microsoft has jumped onto the bandwagon; and there are many companies offering container technologies. Docker, Ansible, and Windows containers are a few that are available in the market.

About the Author