DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Automating Unix Security Across Hybrid Clouds
  • Docker Hardened Images for Container Security
  • Advanced Docker Security: From Supply Chain Transparency to Network Defense
  • How Migrating to Hardened Container Images Strengthens the Secure Software Development Lifecycle

Trending

  • How to Prevent Data Loss in C#
  • Architecting Sub-Microsecond HFT Systems With C++ and Zero-Copy IPC
  • Engineering LLMOps: Building Robust CI/CD Pipelines for LLM Applications on Google Cloud
  • Smart Deployment Strategies for Modern Applications
  1. DZone
  2. Software Design and Architecture
  3. Containers
  4. Container vs. VM Security: Which Is Better?

Container vs. VM Security: Which Is Better?

Which virtualization technology will keep you more secure?

By 
Eric Goebelbecker user avatar
Eric Goebelbecker
DZone Core CORE ·
Aug. 21, 22 · Opinion
Likes (1)
Comment
Save
Tweet
Share
14.4K Views

Join the DZone community and get the full member experience.

Join For Free

Containers and Virtual Machines (VMs) have a lot in common. They both make using IT infrastructure more efficient, but they do it in different ways. While both solutions can often solve the same problem, one of them is usually the better choice.

In this post, we're going to look at the security of containers and VMs. Is one more secure than the other?

Containers vs. VMs: What's the Difference?

Before we delve into security, we need to start with a quick overview of VMs and containers, and how they differ. These differences have a direct effect on their security profiles.

What’s a Virtual Machine?

A VM emulates a physical computer. It uses software to simulate hard drives, memory, CPUs, and graphics cards. So, you can run a virtual Linux system on a Windows laptop. You can even run a complete Windows system inside another. This is a useful technique for testing software on different versions of the same OS without more than one computer.

VMs run on hypervisors that manage access to the underlying hardware. Hypervisors are lightweight processes and can handle many virtual machines on a single computer.

What’s a Container?

Containers take a different approach to virtualization. Instead of running an entire emulated system, they package an application's dependencies, including the operating system, into a single package. You can run that package on any system that supports the container system. So, for example, you can run a Linux application in a container on a Mac.

Instead of a hypervisor, containers run on the underlying operating system, but they're still isolated. The operating system manages access to memory, disk, and OS resources.

Containers are lighter-weight than VMs, but that doesn't make them better. They solve a different problems. A VM emulates an entire computer. A container runs a single application.

Container vs. VM Security

Virtual machines have strong isolation between each other and their host. Since they don't share any resources, compromising one VM doesn't help you gain access to others. For example, if an attacker successfully breaches a VM and tries a denial-of-service (DOS) attack, the hypervisor limits the resource the compromised system can have, so the attack won't disable the host system or hurt the other VMs.

That said, a VM runs an entire operating system, so it has the same attack surface as an actual system. You need to secure your VMs the same way you do any other system. Usually, the first step in securing a VM is turning off or removing anything that isn't needed.

Containers only run a single application. So in theory, they have less attack surface than a VM. If a container has a vulnerability, it's likely to be in the application that's running in it, and that weakness would be there if it ran in a VM or on an actual system.

But containers share an underlying operating system. They're isolated from each other by a kernel, not a hypervisor. With Docker, they're isolated by a Linux kernel, and the Linux kernel has had vulnerabilities in the past. Docker has had vulnerabilities too, like the Doki malware that took advantage of Linux kernel flaws to target containers.

If an attacker compromises a container, they can still y have a better chance of affecting the other containers than they do VMs in a similar scenario. To reuse the example above, they can launch a DOS attack that may harm the underlying OS or the other containers.

Which One Is Better?

This is the wrong question, and if you're choosing VMs or containers based on how secure they are, you're ignoring the fact that they're not the same tool.

On balance, both virtualization technologies enjoy about the same level of security. They're very different tools, and the precautions you need to take depend on the tool and how you plan on using it.

Virtual screening Docker (software) operating system security

Opinions expressed by DZone contributors are their own.

Related

  • Automating Unix Security Across Hybrid Clouds
  • Docker Hardened Images for Container Security
  • Advanced Docker Security: From Supply Chain Transparency to Network Defense
  • How Migrating to Hardened Container Images Strengthens the Secure Software Development Lifecycle

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook