Three Models of Isolation
Unikernels, containers, and virtual machines all solve the same problem — running applications in isolation — but they make very different trade-offs. Understanding these differences is essential for choosing the right tool.
Virtual Machines (VMs):
A VM runs a complete, general-purpose OS (Linux, Windows) on top of a hypervisor. The hypervisor emulates hardware, and the guest OS manages that virtual hardware. VMs provide strong isolation (hardware-level) but carry the full weight of a complete OS — gigabytes of disk, seconds of boot time, hundreds of megabytes of RAM just for the OS itself.
Containers (like Docker):
Containers are lightweight because they share the host machine's Linux kernel. The container runtime uses Linux kernel features — namespaces (to isolate process IDs, network interfaces, and filesystems) and cgroups (to limit CPU and memory usage) — to create the illusion of isolation. Containers boot in milliseconds and use minimal overhead. However, if a vulnerability in the shared kernel is exploited, an attacker who escapes the container is on the host kernel, with potential access to all other containers on the same machine.
Unikernels:
Unikernels do not share a kernel. Each unikernel brings its own tiny, specialized kernel and runs directly on the hypervisor. They achieve hardware-level VM isolation (each unikernel is a separate VM from the hypervisor's perspective) while matching or beating container-level size and boot time.
The Security Advantage
Because unikernels contain only the minimum code required to run the application, their attack surface is dramatically smaller than either VMs or containers.
Consider what an attacker finds after compromising a unikernel running a web server: no shell (/bin/bash does not exist), no package manager (apt, yum — not present), no file download utilities (curl, wget — absent), no SSH daemon, no cron jobs, no other processes. The attacker has compromised the web server process, but there is no environment to pivot from. Lateral movement becomes nearly impossible.
This property — the absence of tools rather than the presence of defenses — is sometimes called implicit security through minimalism.
Interviewers frequently ask: "How are unikernels more secure than containers?" The weak answer is "they're smaller." The strong answer is: "Unikernels provide hardware-level VM isolation (each runs as a separate hypervisor guest, not sharing a kernel) while also eliminating the attack surface that enables post-exploitation — no shell, no utilities, no other processes. Containers share the host kernel, so a kernel exploit can break container isolation entirely. Unikernels don't have that exposure."