Source: Open Source China community

Link: www.oschina.net/news/90833/linux-containers-vs-virtual-machines

Original: www.datamation.com/open-source/linux-containers-vs-virtual-machines.html

Since containers on Linux have become popular, understanding the difference between Linux containers and virtual machines has become trickier. This article will provide you with detailed information to understand the differences between Linux containers and virtual machines.

Linux Containers vs. Virtual Machines — Applications vs. operating systems

The first thing to know about containers and virtual machines is that one is for applications and the other is designed for operating systems. This is why you often see enterprise applications running on containers rather than on their own virtual machines. There are some advantages to using containers on virtual machines.

One of the biggest advantages of a container is that it can reserve fewer resources than a VIRTUAL machine. Keep in mind that a container is essentially a single application, and the virtual machine requires more resources to run the entire operating system.

If you need to run MySQL, NGINX, or other services, using containers is essential. However, if you need to run a full LAMP stack on your own server, it’s better to run a virtual machine. Virtual machines have greater flexibility, allowing you to choose your operating system and upgrade as you see fit. In contrast, running the configured application container is isolated in terms of the host’s operating system upgrade.

Linux Container vs Virtual Machine – Use case scenario

One of my favorite reasons for using containers is to use the Linux library version. For example, suppose you need a specific version of Python to develop your application. Then, when you update on the box where the application is running, you suddenly find that the Python version has changed, causing the application to not work properly.

Another advantage of using containers is that you can put an application into a container and run it on any operating system that supports the type of container you’re running. When you want an application that runs on a different Linux distribution. By using containers, you can run similar application environments on a variety of distributions. Containers provide portability.

Containers are more viable for fast cross-distribution deployments, while virtual machines are better for single applications like running the LAMP stack.

Linux Containers vs Virtual Machines – Security

Virtual machines offer more security than containers. This is not to say that containers cannot be secured, but that the default virtual machine provides greater isolation. Remember that containers can share system resources while virtual machines cannot.

When running containers, you can take steps to reduce the risk, including avoiding superuser permissions, making sure you get containers from trusted sources, and keep them up to date. Some containers are digitally signed, which helps determine that you can get containers from trusted sources.

Finally, you need to maintain the container’s single functional responsibility. Once you start combining software responsibilities under one container, you’ll find that virtual machines are best. To reiterate, containers are for single-purpose applications and virtual machines are for multi-purpose applications. Stick with it and you’ll be better off in terms of security and overall functionality.

Linux Containers vs Virtual Machines – Choose the right tool

Regardless of the virtual machine or container type, the key to choosing the right fit for your needs is the ability to research each option. In the container space, Docker provides a powerful enterprise solution. This attracts companies that are looking at Docker containers, because companies know they can get the support they need if anything goes wrong. Docker is a user-friendly choice for enterprises, especially in Docker Swarms. Compare Docker Swarms to Kubernetes, which is much more complicated to set up in an advanced environment.

Going back to virtual machines, I’ve always found that Virtualbox provides a better desktop-oriented virtual machine environment. VMware does all kinds of products on the server side, VMware has all kinds of virtual machine solutions from storage to cloud server solutions, and other options (various hypervisors, etc.). But I think VirtualBox and VMware represent two areas of desktop-to-server virtualization very well.

Linux Containers vs Virtual Machines – the winner?

Consider the following before deciding between a container and a virtual machine. If you choose containers, you can run containers on a virtual machine. This is important to understand, because there are no clear winners or losers. In fact, the two technologies have very different requirements.

Containers will continue to attract media attention because they allow users to run more efficiently with less hardware. Virtual machines, on the other hand, still dominate the server and cloud space.

What I think is worth watching is the thing between Kubernetes and Docker Swar. I think it’s important to look at how these two container management techniques work and which one will become the standard. For a while, it felt like Docker. Now, however, the Kubernetes occupy more camps. Perhaps over time we will start to see Kubernetes make headlines and become the number one person in the container camp.

Do you believe that containers are surpassing virtual machines? Maybe on the contrary, you think the two technologies will merge in the future? Anyway, click on the comments and let us hear your views. Either way, whether you’re running a complex container or a virtual machine, I’d like to hear what you think about them.