How would you briefly but precisely explain the difference between Virtual Machines (VMs) and Docker in technical interview?
Docker and virtual machines both provide virtualization, but they differ in their approach. VMs, like a virtual computer, run a full operating system inside a hypervisor, which acts as an intermediary between the hardware and the guest OS.
Docker, on the other hand, uses containers which run directly on the host’s operating system kernel, sharing it with other containers. This makes Docker significantly lighter and faster to start and deploy.
In my previous role, we used VMs to run legacy databases and applications that required specific operating systems. For our newer microservices, we transitioned to Docker containers to improve resource efficiency and enable quicker development cycles.