By placing Docker containers on dedicated servers, organizations gain portability and stability. Expert Christopher Tozzi explains why the choice is sometimes made in favor of virtual machines.
For what you may need containers, you already understand. But do you know which type of server is more suitable for them? Is it really better for hosting platforms like Docker or any other similar container management environment to use dedicated servers than virtual machines?
The answer, of course, depends on a variety of parameters. The article discusses such parameters, as well as arguments for and against the use of containers on dedicated servers or virtual machines. I will focus on Docker, but the findings generally extend to any container management platform.
')

Dedicated server or virtual machine?
Comparing the pros and cons of dedicated servers and virtual machines for hosting a software environment is not a new task. Technical executives thought about it even when virtualization began to be widely used in data centers in the 2000s, long before Docker appeared.
In short, the main advantages of a dedicated server are as follows:
- Relatively high speed . System resources are not spent on hardware emulation;
- Equipment resources are used in full, because it does not stand idle in a period of high demand;
- Simplified administration. The infrastructure contains fewer hosts, networks, and disks.
With virtual machines, in turn, offer the following benefits:
- You can easily move applications between by moving virtual machine images from one server to another;
- Isolation of applications running on different virtual servers. This solves security problems and helps reduce administrative complexity;
- The ability to preserve the uniformity of the software environment for the entire infrastructure, deploying all applications on the same type of virtual machines, even if the physical servers are different.
But using virtual machines has
some drawbacks . These include the following:
- Server resources may not be fully utilized. For example, if you allocate space on a server for storing an image of a virtual machine, then this amount of memory can no longer be used for other purposes, even if the virtual machine associated with the disk does not use the entire allocated amount.
- Using virtual machines, you cannot work with physical equipment directly. For example, if you want the computational operations to be performed by the GPU instead of the virtual machine, then nothing will work out — at least in simple ways — since the virtual machine works out of touch with the corresponding server environment.
- As a rule, virtual machines do not work as fast as physical servers, since their resources are spent on emulating hardware for a virtual server.
To overcome these limitations, system administrators may resort to some techniques based on modern virtualization platforms. For example, you can create a dynamic
disk image that will expand in volume as it is used by the virtual machine. That is, the amount of memory will not be locked until it is actually required by the user. You can use a backhaul so that in certain cases the virtual machine has direct access to the physical hardware.
However, these tricks are not always effective. Apply this approach can not be on all types of hosts and guest operating systems, and, in general, all this flows into an additional burden for the administrator. If the applications you intend to use need direct access to the physical equipment, then it is better to immediately run them on such equipment.
Or you can
run applications in containers on a physical server, and you can kill two birds with one stone.
Square of the circle: how containers work on a dedicated server
Using containers on a physical server gives you many of the benefits of virtual machines while avoiding the disadvantages of virtualization.
Containers on dedicated servers allow you to:
- Get access to hardware without resorting to transit methods. The application runs on the same operating system as the server.
- Use system resources efficiently. Although it is possible to limit the resources allocated to the container for calculating, storing and transmitting data, as a rule, it is not necessary to allocate these resources exclusively for the operation of one particular container. That is, the server can allocate system resources as needed.
- Get the performance of a dedicated server for applications due to the lack of a hardware emulation level separating them from the host server.
In addition, when using containers with a dedicated server, you will have access to the benefits that, as a rule, are associated only with virtual machines, namely:
- The ability to run applications in a moveable environment that can be quickly transferred from one host server to another.
- Isolation of applications. Perhaps with the help of containers you will not achieve the same isolation as on a virtual machine, but their functionality allows administrators to prevent application interaction and restrict the rights and use of resources for each container.
In general, containers on a dedicated server allow you to
cram a non-inevitable solution to an unsolvable task. You get the advantages of a dedicated server: the speed and direct access to the physical server - and the advantages of virtual machines: portability and the ability to isolate programs.
Why not always place containers on a dedicated server. You are probably wondering, why don't containers always run directly on a dedicated server? If this approach provides all the benefits, why do we need any other?
Consider the following disadvantages of hosting a container on a dedicated server and not on a virtual machine:
- Updating the physical server is difficult. If you want to replace the server with a new one, you will have to recreate the software environment of the container from scratch on the new server. If the container's software environment were part of a virtual machine image, then it would be possible to simply move it to a new server.
- Most of the cloud services insist on using virtual machines. There are also cloud hosting with dedicated servers, for example, OnMetal from Rackspace or Bare Metal Cloud Service from Oracle. But in general, working with the cloud involves the use of virtual machines. If you want to use the cloud platform for container operation, you will have to use virtual machines.
- Containers do not support all hardware and software settings. Nowadays, you can host almost any kind of operating system on a virtualization platform like VMware or on KVM running on almost all operating systems and servers. But the Docker features are limited. When hosted on a physical server, it only works on Linux and some Windows servers. This means that if your dedicated server uses, say, Windows Server 2012, and Docker does not support it now, and you want to host the Docker, you will need to install a virtual machine in addition to the Windows server to meet the requirements of the Docker operation.
- You cannot run Linux containers on a Windows server and vice versa. This disadvantage means that Linux containers only work on Linux servers. Suppose you have a dedicated server with Windows, and you want to run a Docker container on it to host an application developed for Linux. You'll have to install a Linux virtual machine on a Windows server and use it as a medium to host the Docker.
- On a dedicated server, you cannot return to the previous state. On most modern virtualization platforms, a very useful feature is implemented: you can snapshot a virtual machine and go back to that state later if necessary. It’s not possible to do this on a dedicated server (technically, it may be possible to use the backup functions of the operating system or file system itself, but this process is not as smooth as on a virtual machine). And in general, snapshots, and returning to the previous state for containers are meaningless concepts. The containers themselves are something ephemeral, they have no previous state. In the end, the easiest return to the previous state can be implemented only on a virtual machine.
Conclusion
It's not easy to decide whether to place containers on a dedicated server or on a virtual machine. You will have to compare all the pros and cons to determine which option is more appropriate for your organization.
It is pleasant that regardless of where the containers are placed, you will still benefit from the basic properties of containerization, including application portability, scalability and agility.
If you choose a virtual server or a dedicated server for your projects, try using the VDS.menu and DEDICATED.menu directories.