For many years we started looking for the “virtualization” of computers that is, having the possibility of being able to use different “virtual” computers within a single physical computer. Which is carried out with software that simulates having more than one computer environment, with its own operating system, programs, processes and files. Now there’s the possibility of being able to change from one single physical computer, even from one virtual computer to another to perform a specific process. This brought great advantages not only technical, but also practical and economic.
But this technology that allows us to work with multiple virtual machines (VM’s) has not stopped there, but there have been other new technologies that also work in the virtual environment but in a different way. Let’s also talk about containers.
How exactly does a virtual machine and a container work? How do they differ and what advantages do one have over the other? Let’s talk first about virtual machines.
A virtual machine is one that emulates a complete computer. In very simple words, it is a software that can pass itself off as another device -like a PC- in such a way that you can run another operating system inside it. It has its own hard drive, memory, graphics card and other hardware components, although all of them are virtual.
When we say that its components are virtual does not mean that they do not physically exist. In fact, the hardware resources installed on the physical computer will be distributed in the virtual machines that are available. For example, suppose we have a desktop PC with 8 GB of RAM and 500 GB of hard disk. Now imagine that we have created a virtual machine within our PC operating system and that we want to allocate RAM and hard disk space. Maybe we can assign 4Gb of RAM and 100Gb of hard disk. That would leave our PC “host” with only 6Gb of RAM and 400 Gb of Hard Disk. This is very beneficial because we can work with different virtual machines for different purposes and even different operating systems, although they are not the same as the physical PC. As for example, we can have a virtual machine with Linux running on a Windows computer. The following image shows an example of how 2 virtual machines are configured on a PC:
This technology has been very beneficial, especially in server environments for the following reasons:
- Being able to test other operating systems: Installing an operating system on your PC is a long, boring and difficult process to reverse if you are not satisfied with the results. Thus, when there is a new version of Windows, it is easier and safer to test it by installing it on a virtual machine than on your hard drive. If something goes wrong, you erase them and it’s over, without risking losing a lot of time or your data.
- Can run old programs. What happens when your business depends on software that has not been updated for 20 years? If you cannot modernize the software you have no choice but to continue loading it into an operating system of its time. With a virtual machine this old system can work on current hardware instead of on an obsolete computer.
- Be able to use applications available for other systems. It is also possible that you need a virtual machine to run applications that have been developed for a different operating system than the one you are using. For example, to use a Windows application on MAC OS, or vice versa.
- Because virtual servers are not a physical machine, you can expand your capacity at any time and move on to using more resources (RAM, HDD, etc.). In this way, the client can adapt its server in case it happens to host more websites or increase its traffic.
- Be able to save resources. Expenses are reduced in more hardware, in computers and servers. As well as in electrical energy and maintenance time.
- Backups and disaster recovery: Disasters such as leaks, floods, energy shortages, cyber-attacks or thunderstorms are unexpected and serious as there may be total damage to the operating system or data loss. It is much easier to backup and restore the virtual machines that are installed on a physical server in the server room that would have to be assembling and configuring different physical servers.
In the case of the servers, we may not even need an operating system but instead put the VM Host Software directly and create the virtual machines right there, as can be seen in the following image:
Docker is an open source software platform where we can create “containers”, which simple definition is a lighter virtual machine, meaning it’s less demanding with the resources of the physical computer where they run. This have been especially useful for developers who want to test or use their applications in any environment. Some of the benefits of Docker Containers are:
- Portability: The Docker container can be deployed in any other system (that supports this technology), which saves us having to install in this new environment all those applications we normally use.
- Lightness: The size of containers have no comparison with other conventional virtualization systems. For example, VirtualBox and any Linux distribution will be around 1Gb by just doing the clean install, so space reduction is substantial
- Self-sufficiency: A Docker container doesn’t include the whole OS, but only the libraries, files and configuration necessary to run. It also takes care of the container management and the applications in it.
While in virtual machines we have virtual machine host software (Hypervisor) in containers we have a container engine which is used to running and ending the content. The following diagram is a visual representation of Dockers containers’ structure:
Another advantage of containers is that they can be used along with virtual machines with no conflicts, having twice the benefit as we can see on this diagram:
In conclusion as we can see there are common and different benefits from VMs and Containers. If you are a server or network admin VMs will be beneficial enough for that purpose. But if you’re into DevOps you may want to go with Docker Containers. And even why not go with both and get the best from both worlds.