Beer and tacos and the metaphorical origins of Docker containers
containers kubernetes beer tacosRecently, after spending a big part of the day trapped in Kubernetes ecosystem YAML hell, I was desperate to get out of the house. I went to Faction Brewing, which is a local brewpub, for a beer and some tacos. But even there, I couldn’t escape from containers. The brewery is across the Oakland Estuary from the port of Oakland and off in the distance I could see a couple of cargo ships that were being loaded with containers. Not surprisingly, as I drank my beer, I started to think about the metaphorical origins of Docker containers
Containers the metaphor
Docker containers draw their metaphorical inspiration from inter-modal shipping containers. As the excellent book The Box describes, shipping was inefficient, and expensive before the invention of inter-modal shipping containers. For example, in order to load a ship, longshore men had to manually load and stow tens of thousands cargo items of all shapes, sizes and weights, which was very labour intensive, and dangerous. Shipping containers revolutionized global trade. Goods are packaged and secured in containers of standardized sizes that are easily transported to and from ports and rapid loaded/unloaded from ships. This resulted in streamlined logistics and improved efficiency in global supply chains.
In the same way, Docker containers provide a standard way to package and run applications. Once an application has been packaged as a container image, its technology stack no longer matters. A container is created and managed regardless of whether it is, for example, a Java or GoLang application. Similarly, the details of the execution environment that runs the container are hidden from the application.
Containers are not black boxes
While it might appear that containers - shipping or Docker - are black boxes that can be treated uniformly, they have distinct characteristics that affect how they are handled.
Ignoring a shipping container’s attributes can be dangerous
Although a shipping container has a standardized size, it has various attributes that can influence where it is placed on a cargo shop Its weight is a critical concern since unless a ship has the correct weight distribution it might buckle or capsize. This requirement even affects the order in which containers are loaded onto a ship. Moreover, a shipping container has other attributes that determine placement such as power needs for refrigeration and whether its a fire hazard.
Docker containers have attributes that affect placement
Similarly, Docker containers have attributes that affect where they are placed on the infrastructure. For example, the Kubernetes scheduler considers the following attributes when placing a container (strictly speaking a Pod, which is a collection of containers) on a node including the container’s resource requirements - CPU, memory, storage, etc., and constraints such as affinity and anti-affinity.
Docker containers have externalized configuration
In addition to infrastructure-level attributes, a container typically has externalized configuration that is used to customize its behavior. For example, an application service needs to be configured with the location of a database. This configuration is typically provided via environment variables or configuration files.
Final thoughts
To sum it up, shipping containers, which are the metaphorical inspiration for Docker containers, revolutionized global trade, while Docker containers revolutionized application packaging and deployment. Although they may seem like black boxes, both types of containers have unique attributes that impact their handling and placement. Shipping containers have attributes such as weight, power needs, and fire hazards, while Docker containers have attributes such as resource requirements, constraints on placement and externalized configuration.
One interesting historical fact is that the Port of San Francisco thought that containers were a passing fad where as Oakland embraced them. That’s why today container ships ignore San Francisco and sail to Oakland. An important reminder that it’s important to embrace change.