First, let me immediately say that the title of this blog post is almost click-bait. I do prefer virtual machines to Docker containers but this is due almost entirely to what I use VMs and containers for.
Briefly, a virtual machine is software that simulates an entire computer — everything — operating system, programs (applications), UI, and so on. As such, a VM is (almost) a standalone entity. A Docker container holds applications but is dependent on other parts of the Docker ecosystem, in particular a shared host operating system. The image below shows an example of a virtual machine.
What I like most about VMs is that working with them is almost exactly like working with a physical machine. It looks the same, feels the same, and works the same. There’s no conceptual friction. Docker containers on the other hand, require a bit of knowledge and there’s a small layer of abstraction difference. For example, you have to learn about things like “docker run -it foo –name mycontainer”
Also, and this is key for me, a Windows virtual machine is completely part of the Windows ecosystem, but Docker is really part of the Linux/Ubuntu ecosystem — and I (now) do most of my work in a Windows environment. Docker is mostly a shell/text based system but a VM deals with a GUI environment effortlessly.
Now, all of that said, Docker containers are less expensive to operate and they’re much smaller in size. My most common usage case is when I’m working with machine learning systems such as Keras/TensorFlow or CNTK. For me, it’s easier to spin up a large but conceptually simple virtual machine and then use it, than it is to create and use a Docker container.