What is the difference between a container and a virtual machine?
A VM virtualises hardware: each VM runs a full guest OS on a hypervisor, so it is heavy (GBs) and slow to boot (minutes) but strongly isolated.
A container virtualises the OS: containers share the host kernel and package only the application and its dependencies. They are lightweight (MBs), start in seconds and give consistent environments across dev and prod. Isolation is weaker than a VM, which is why sandboxing and runtime hardening matter.
In practice: containers for packaging and scaling application workloads, VMs (or managed node pools) as the underlying infrastructure, and sometimes both, for example a Kubernetes node running many pods.