Architectures of Docker Containers vs. Virtual Machines

Photo by Ian Taylor on Unsplash

Architectures of Docker Containers vs. Virtual Machines

Let's go through a very brief comparison of the architectures for Docker containers and virtual machines (VMs).

Containers vs. VMs

Containers virtualize the operating system instead of the hardware, abstracting code and dependencies at the app layer1. VMs instead abstract the physical hardware and include copies of the OS, the application, and more.

The benefits of containers involve taking up much less space than VMs, allowing for more applications, and having faster start/reboot/stop times. However due to their architecture, containers may have drawbacks in scenarios where certain processes are using up a significant amount of resources on the container host, therefore causing performance issues in other containers.

Architecture diagrams

The following is a visual comparison of the architectures of VMs (left) and containers (right) from Adrian Cantrill's free Docker Fundamentals course:

A diagram of VM architecture vs. container architecture from Cantrill's course

Notice how VMs require copies of entire operating systems, which can take up a significant amount of storage at scale compared to containers. You can imagine containers as processes that run on the Docker engine, which is a container runtime that enables containerized applications to "run anywhere consistently on any infrastructure". The "it works on my laptop, but not in production!" issue is nullified thanks to the Docker engine2.

Here is another visual of containerized applications from Docker's article on containers1:

Container architecture diagram

Working together with containers and VMs

We can use VMs and containers in tandem in certain cases, such as using VMs as Docker hosts.

"For instance, your application may need to interact with a database that resides in a VM. Provided that the right networking is in place, your app can interact with that database seamlessly."3

Conclusion

Overall we can see that Docker containers and VMs have different architectures that can be used to solve different issues, but can also be used together within the appropriate circumstances.

For more in-depth knowledge on Docker containers, comparisons with VMs, and more, check out the articles linked in the footnotes. If you want to learn more about Docker and AWS, I recommend Adrian Cantrill's courses at learn.cantrill.io.

Let me know if this post helped you with understanding architectures of Docker containers and VMs, and subscribe to the newsletter below for getting notified for my new blog posts!


1. Docker, "Use containers to Build, Share and Run your applications".

2. Docker, "The Industry-Leading Container Runtime".

3. Coleman, Mike, "Containers and VMs Together".