How are containers different from virtual machines? 

In a nutshell,  a virtual machine resides on top of a Hypervisor, like ESXi or KVM which emulates hardware (Memory, CPU, Storage, etc.). In other words, each virtualized application contains the application, binaries and libraries and additionally Guest OS.

On the other hand, containers run in user space right on top of the host kernel, more precisely, containers runs directly as a process on top of the Host OS.

The figure below shows a fundamental difference virtual machines and containers.


In summary, containers are great for deploying applications and testing because of simplicity and speed. Additionally, containers are more resource-efficient, because there is no need to create Guest OS comparing to virtual machines, it means they reduce the virtualization overhead for tenants or consumers.