Whats the difference between a Docker container and a Virtual machine?

Published: Tuesday, Jul 12, 2016 Last modified: Thursday, Feb 15, 2024

Docker is much faster and more productive to work with than a Virtual machine. It’s basically a front end on Linux containers aka LXC.

Ideally Docker is running on a “bare metal” machine since it does not need to be virtualised. It runs a lot faster, but admittedly you probably won’t see the performance boon if you are running on a already virtualised VPS like EC2 or MacOS. A lightweight Linux OS like CoreOS or RancherOS makes more sense for running Docker containers.

Docker runs whole services in containers which are isolated and can be controlled much like a Virtual machine, but without any complex hardware abstractions.

But Docker is much more; For example the https://hub.docker.com/ is a public repository where you can almost pick a pre-packaged service off the shelf. Instead of running Nginx packaged by your distribution for example, you can run the official nginx Docker image from Nginx, who know the software and dependencies best.

Docker defines a Dockerfile which like debian/rules or Arch’s PKGBUILD is a very succinct way of describing how a service is packaged and furthermore deployed in a network and run.

Docker has a layered filesystem to make it easy for developers to isolate changes and to iterate quickly. You can painlessly keep current or roll back and forth atomically using image tags.

Docker has a raft of handy tools in their popular ecosystem to help network containers and manage filesystem mounts between the container and host. Compose is a advanced tool with a definition language for managing a whole formation of Cloud services. A complex network of services can be launched and maintained using it.