Containerisation using Docker is the new way of virtualizing servers to provide services. Containers have the benefit of sharing common libraries and binaries which means they are less resource intensive than virtualization. A single VPS or server can host hundreds of docker containers with minimal effort.

Docker containers are also very fast as they don’t have to boot an entire OS. This makes them ideal for scaling as orchestration software like Swarm or Kubernetes can start up more machines as needed, then shut them down when traffic to the application subsides.

Containers are portable which means you can move them from one Docker server to another quite easily and because they contain the entire environment in a single file, you never have the issue of “but it works on my machine”

Benefits of containers vs virtual machines

Docker Containers
Virtual Machine
Linked VMs
Boots in minutes
Boots in milliseconds
Variety of guest OSes
Limited to Linux
VMs are dependent on hypervisor
Containers are portable
VMs can be multiple GB’s in size
Containers are lightweight
Requires more memory
Require less memory space
Hardware virtualization
OS virtualization

Docker swarm is a container orchestration tool that comes with Docker. It provides clustering and scheduling of Docker containers to allow system administrators and developers to manage multiple docker nodes as a single virtual system.  A node is the system that hosts docker containers.

This allows for high availability and load balancing of applications.

Docker Swarm can distribute containers in 3 ways across the nodes it controls:

  • Spread — balances containers across the nodes based on the nodes’ available CPU and RAM, as well as the number of containers it is currently running.
  • BinPack — Schedules containers to fully use each node. Once a node is full, it moves on to the next in the cluster.
  • Random — Chooses a node at random.

We use 3rd party tools like Portainer so everything can be managed via a web interface so there is no need to learn the docker command line tools. We can also look at installing Watchtower to keep an eye out for new images and automatically deploy them when needed.