Emulation vs Virtualization vs Containers Explained
Emulation translates a foreign CPU, virtualization runs guest code natively under a hypervisor, and containers share the host kernel. Here is how they differ.

People say "it runs in a VM" about three very different things, and the difference decides speed, isolation and what you can run at all. Emulation, virtualization and containers answer the same question, how do I run software that expects its own machine, with three different mechanisms. This post separates them using QEMU and Linux 6.12 as the examples, so that when someone says "just use a VM" you know which of the three they mean. The wider picture is in the complete guide to virtualization for systems programmers; here the goal is a clean mental model you can apply in a minute.
Emulation: a program pretends to be a CPU
An emulator reads the instructions of the guest program and carries out their effect in software. The guest can be any architecture the emulator knows. QEMU's translator, called TCG for Tiny Code Generator, reads a block of guest instructions, translates it into host machine code, caches the result and runs it. The guest never executes on the real processor as itself.
You can see this with a foreign binary. Suppose hello-arm64 is a statically linked Arm 64-bit Linux program and your host is x86-64:
file hello-arm64
qemu-aarch64 ./hello-arm64hello-arm64: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), statically linked
hello from arm64qemu-aarch64 is QEMU's user-mode emulator. It translates the Arm instructions and forwards the program's system calls to the host kernel. The same idea at machine level is qemu-system-aarch64, which emulates a whole board with devices and its own kernel.
Emulation works across architectures, and it is the only option when the architectures differ. The cost is that every guest instruction becomes several host instructions, plus the translation work itself. It is also the easiest to make deterministic and debuggable, because the emulator controls every step.
Virtualization: the guest runs on the real CPU
Virtualization keeps the guest's instructions as they are. The processor executes them directly at native speed. The hypervisor only gets control when the guest does something sensitive, such as touching an I/O port or an unmapped page. Intel VT-x and AMD-V make that possible by adding a guest mode to the processor. The guest and host must share an instruction set, because nothing translates.
On Linux, KVM provides this. A user space program opens /dev/kvm, creates a virtual CPU and runs it. QEMU does that and supplies the virtual devices. The only change to the QEMU command line is one flag:
qemu-system-x86_64 -enable-kvm -cpu host -m 2G -nographic -kernel bzImage \
-append "console=ttyS0 root=/dev/vda" -drive file=rootfs.img,if=virtio,format=rawWith -enable-kvm the guest kernel runs on the host CPU and only exits for device access and similar events. Without it, QEMU falls back to TCG and emulates an x86 CPU on an x86 host, which is correct but slow. The same guest image works both ways, which makes it handy to compare.
You can confirm which mode a running guest uses from inside it:
grep -m1 -o 'hypervisor' /proc/cpuinfohypervisorThe hypervisor flag is set from CPUID leaf 1, ECX bit 31, which hypervisors raise for their guests. Note that both KVM and TCG set it, so it tells you "this is a VM", not "this is accelerated". For that, check on the host that /dev/kvm exists and that QEMU printed no fallback warning.
Containers: one kernel, many views
A container does not run a second kernel. It is a set of ordinary host processes whose view has been narrowed by three kernel features, all documented in the Linux man pages: namespaces (namespaces(7)) change what the process sees, control groups limit what it may use, and seccomp restricts which system calls it may make.
A one-line demonstration shows a private process ID space and hostname without any image or runtime. Run it as root:
unshare --pid --uts --fork --mount-proc sh -c 'hostname sandbox; hostname; echo $$'
hostnamesandbox
1
build-hostInside, the shell is process 1 and the hostname is sandbox. Outside, the hostname is untouched. There was no hardware virtualization, no second kernel and no translation. The shell is a normal process the host scheduler runs, which is why starting a container is as quick as starting a process.
That shared kernel is the whole trade-off. Containers inherit every kernel bug and every configuration of the host. A process that escapes the namespaces is already on the host kernel with its privileges. A virtual machine puts a much smaller interface between the guest and the host: the hypervisor and its device models.
What each one costs
| Property | Emulation | Virtualization | Container |
|---|---|---|---|
| Guest architecture | Any the emulator supports | Same as host | Same as host |
| Where guest code runs | Translated, in the emulator | Directly on the CPU | Directly on the CPU |
| Own kernel | Yes | Yes | No, shared |
| Typical boundary | Emulator process | Hypervisor and VMM | Kernel namespaces and filters |
| Startup | Slower to boot a full guest | Boots a full guest | Starts a process |
| Needs hardware support | No | Yes (VT-x, AMD-V or equivalent) | No |
The speed ordering is no surprise. Containers add almost nothing, virtualization adds overhead on exits and nested page walks, emulation adds overhead on every instruction. Do not put numbers on that ordering from memory; measure your workload, because I/O-heavy and compute-heavy programs sit in very different places.
Mixing them is normal
The three combine in practice. A cloud provider runs your container inside a virtual machine, so you get image packaging plus a hardware boundary between tenants. A CI system runs QEMU user mode inside a container to build Arm images on x86 runners, which is emulation inside a container. A kernel developer runs a KVM-accelerated QEMU guest to test a driver, then switches to TCG to reproduce the same bug on a different architecture.
Docker's multi-architecture builds are a good illustration. On an x86 host, building an Arm image uses qemu-user-static registered with binfmt_misc, so each Arm binary the build runs is transparently emulated. The container is still a container, but the instructions inside it are emulated one block at a time. The post on multi-architecture images shows the setup.
How to choose
Ask three questions in order.
Is the target architecture the same as the host? If not, you need emulation, and nothing else helps.
Do you need a different kernel, or a strong boundary against untrusted code? If yes, use a virtual machine, and KVM when the architecture matches.
Otherwise, do you only need to package and isolate applications on a kernel you trust? Use a container.
For kernel and driver work we reach for KVM-accelerated QEMU first, because you get your own kernel, serial console and gdb stub with near-native speed. For cross-architecture checks, we use TCG. For application deployment, containers.
Where each answer fails
A container cannot run a different kernel version or a Windows program on a Linux host. A KVM guest cannot run on a machine without hardware virtualization enabled, and cannot cross architectures. An emulated guest is slow enough that a compile that takes minutes natively can take much longer, so heavy builds are better done with a cross-compiler on the host and only the test run emulated. And a container is not a security boundary you should rely on for hostile code unless you add more layers, such as a user namespace, seccomp and a restricted capability set, or put it inside a VM.


