June 28, 2017

What makes Docker containers so popular and more attractive in some cases than virtual machines? The answer is density. Here’s what it means and why it matters.

In the context of computing, density refers to the number of objects that a single physical server can run at one time. If a server can host lots of apps at once by making full use of its resources, it supports a dense deployment environment. In contrast, if the server only runs a handful of apps and its total capacity is underutilized, then it’s a sparse environment.

Docker and Density

The ability to support dense software deployments is a key reason why Docker can be more beneficial in many situations than  virtual machines for deploying an app.

To understand why, you must first recognize that, by their nature, virtual machines are not good at being dense. That’s true for two main reasons:

  • Virtual machines have more overhead. They have to run a full guest operating system, even if they only host a single app. As a result, more of the physical server’s resources have to be dedicated to supporting the environment overhead associated with guest operating systems, leaving fewer resources available to dedicate to apps.
  • When you provision a virtual machine, you usually have to assign it a certain amount of storage, memory and sometimes compute resources. Those resources become permanently attached to the virtual machine until you change the configuration. Even when the virtual machine is not using the resources, they are not available to support other virtual machines on the host server.

In contrast, Docker containers are ideal for creating dense environments in which the host server’s resources are fully utilized but not overutilized. That’s because Docker containers don’t require you to duplicate the functionality of the host operating system by creating guest operating systems inside containers.

In addition, Docker doesn’t force you to allocate a given amount of resources to a container (although you can set resource quotas for individual containers if you want). This means Docker containers are able to make more efficient and dynamic use of the resources from the host. When the demand placed on one container or service decreases, the resources that it was consuming are freed to be used by other services.

It helps, too, that Dockers containers can be distributed easily across a cluster of servers. That helps to ensure that resources are used efficiently and the density of each server is maximized while the risk of an individual server becoming overloaded is minimized.

Conclusion

To date, density hasn’t been an important part of the Docker conversation (though Canonical likes to use the term to promote its system container solution, LXD, which is designed for hosting complete operating systems rather than individual applications). But the concept is helpful for thinking about just why, exactly, Docker has become so popular—and what the key differentiator is between Docker and virtual machines.

Christopher Tozzi

Christopher Tozzi has covered technology and business news for nearly a decade, specializing in open source, containers, big data, networking and security. He is currently Senior Editor and DevOps Analyst with Fixate.io and Sweetcode.io.