When it comes to cloud infrastructure, VMware has long been the go-to standard for its many advantages: its ability to run multiple OS environments that don’t affect each other, the choice of VM types, and its consolidated toolkit that makes VM management easy. However, consider this: What if you had an alternative to VMware that was more lightweight, economical and more scalable? That’s exactly what Docker is - a container technology that lets users develop distributed applications.
So, how are the two different? And how do they complement each other? Let’s find out.
What is a Virtual Machine?
The concept of a virtual machine is simple, really: it’s a virtual server that emulates a hardware server. A VM relies on the system’s physical hardware to emulate the exact same environment on which you install your applications. Depending on your use case, you can use a system virtual machine (that runs an entire OS as a process, allowing you to substitute a real machine for a virtual machine), or process virtual machines that let you execute computer applications alone in the virtual environment .
What is Docker?
Docker is an open source project that offers a software development solution known as containers. To understand Docker, you need to know what containers are. According to Docker, a container is ” a lightweight, stand-alone, executable package of a piece of software that includes everything needed to run it.” And since containers are platform-independent, Docker can run across both Windows- and Linux-based platforms. In fact, Docker can also be run within a virtual machine if need be. The main purpose of Docker is that it lets you run microservice applications in a distributed architecture.
Docker’s architecture is also client-server based. However, it’s a little more complicated than a VM because of the features involved. It consists of four main parts:
Docker Client: This is how you interact with your containers. Call it the user interface for Docker.
Docker Objects: These are your main components of Docker: your containers and images. We mentioned already that containers are the placeholders for your software, and can be read and written to. Container images are read-only, and used to create new containers.
Docker Daemon: A background process responsible for receiving commands and passing them to the containers via command line.
Docker Registry: Commonly known as Docker Hub, this is where your container images are stored and retrieved.
Common Use Cases
Now that you have an idea of what VM and Docker container are, it’s important to understand the potential use cases for both. While they are both more or less used to develop applications, here is where the differences really start.
Real-World Use Case for VMs
Starling Bank is a digital-only bank that was built in just one year on VMs provided by AWS. This is possible because of the efficiency virtual machines deliver over traditional hardware servers. Importantly, it cost Starling Bank just a tenth of traditional servers.
Real-World Use Case for Docker
Paypal uses Docker to drive “cost efficiency and enterprise-grade security” for its infrastructure. Paypal runs VMs and containers side-by-side, and says that containers reduce the number of VMs it needs to run.
- Application development: Docker is primarily used to package an application’s code and its dependencies. The same container can be shared from Dev to QA and later to IT, thus bringing portability to the development pipeline.
- Running microservices applications: Docker lets you run each microservice that makes up an application in its own container. In this way, it enables a distributed architecture.
Docker Containers vs. VMs
At last, we arrive at the big question: how are the two different? It all comes down to what you want to do with them. Below, we’ll mention a few advantages of Docker as opposed to a virtual machine (specifically Docker vs. VMware), and vice versa.
For more details and a Docker vs. VMware comparison, see this page by UpGuard.
Advantages of Virtual Machines
- The tools associated with a virtual machine are easier to access and simpler to work with. Docker has a more complicated tooling ecosystem, that consists of both Docker-managed and third-party tools.
- As mentioned earlier, once you have a VM up and running, you can start a Docker instance within that VM, and run containers within the VM (which is the predominant method of running containers at present). This way, containers and virtual machines are not mutually exclusive and can co-exist alongside each other.
Advantages of Docker Containers
- Docker containers are process-isolated, and don’t require a hardware hypervisor. This means Docker containers are much smaller and require far fewer resources than a VM.
- Docker is fast. Very fast. While a VM can take a at least a few minutes to boot and be dev-ready, it takes anywhere from a few milliseconds to (at most) a few seconds to start up a Docker container from a container image.
- Containers can be shared across multiple team members, bringing much-needed portability across the development pipeline. This reduces ‘works on my machine’ errors that plague DevOps teams.