DEV Community

Oracle Sean  ♠️
Oracle Sean ♠️

Posted on • Edited on • Originally published at Medium

Visual Docker: Introduction

“Containers are like lightweight virtual machines” is a poor analogy

An effective analogy helps expose the parallels between something you already know or understand and the new thing you're learning. The one that springs to mind for me is the comparison between flowing water and electric circuits. I learned it from my high school physics teacher way back in 1982, and to this day, I can't think of a circuit without picturing water moving through different diameter hoses, with sand or constrictions representing resistance and batteries delivering voltage replaced by pumps generating water pressure.

The Water Flow Analogy likens the flow of electricity in a circuit to the flow of water in hoses and through pumps and constrictions. It's an effective and accessible analog for imagining and anticipating how electrical systems behave.

It gives me a mental picture of a real, physical system that mimics the behavior of something abstract and helps me understand and even predict how the circuit works.

Unfortunately, the Docker world doesn't have a good analogy for containers.

When I give talks on Docker and ask people to describe containers, I hear two answers again and again:

  • Containers are control groups (cgroups) and namespaces
  • Containers are like lightweight virtual machines

There are problems with both of these. Saying containers are built from cgroups and namespaces isn't helpful unless you already understand cgroups and namespaces, and chances are that if you do, you probably already have a technical awareness of what containers are!

Since most aren't familiar with these terms, I see most people leaning toward the "Containers are like lightweight virtual machines" comparison. But it has problems, too. It's just not a useful analogy because it doesn't advance our understanding of containers. Why not?

If containers are like lightweight virtual machines, then… what is a lightweight virtual machine? For that matter, what's a virtual machine? Can you describe VMs in non-technical terms that a layperson can understand?

Even if you and your audience understand what virtual machines are, what's this special "lightweight" virtual machine? What makes it lightweight? How is it different from a regular virtual machine? Why not just, "They're like virtual machines?"

An analogy bridges the unknown to the familiar, equating something new to another thing you have experience with or can imagine easily. And a good analogy should work to describe a broad set of behaviors.

Everyone understands that kinking a hose reduces water flow and creates pressure behind it, but "containers are like lightweight virtual machines" doesn't describe anything about containers. It doesn't explain statelessness or immutability. There's no parallel that clarifies the differences between images and containers or accounts for fast startup times.


The Tic-Tac-Toe Analogy

I developed the Tic-Tac-Toe analogy as a better way of visually understanding containers. It's entirely non-technical and describes everything from fast startup times and how containers accomplish high density; to abstract concepts like immutability, persistence, ephemeralness, state, and caching; and constructs and properties like tags, builds, Dockerfiles, layers, union filesystems, and more!

I'll cover each of these in separate posts in this series, beginning with the difference and relationship between images and containers.

Top comments (0)