Virtual machine
A virtual machine (VM) is a computer inside a computer. It has its own operating system, virtual disk and network card. A hypervisor (such as VMware, Proxmox, Hyper-V or KVM) shares the real processor and memory between them. If one VM crashes or is attacked, the others keep running.
Container
A container has no full system of its own; it shares the host's kernel and contains only the app and its libraries. It starts in a second and takes little space. Docker brought simple commands and ready-made images you download and run with one line.
When to use which
- VM: when you need another operating system or strong isolation, for example a separate web server.
- Container: when you want to spin up a service quickly, for example a database, Pi-hole or Jellyfin.
- This website runs in a container inside a virtual machine on a home NAS.