AlgoViz

Docker

easy 26 min

Docker packages a program with its files into an image and runs it as an isolated process called a container.

Remember it

The few things worth knowing cold, and how to make them stick.

Memory hook

Shared tins, your own lid, and a jar for what must stay.

Stackable lunch tins: rice, veg and curry are closed and shared, each guest has one thin lid, and the jar survives washing up.

Cheat sheet

Sees less
namespaces
Uses less
cgroups
Chain
CLI, dockerd, containerd, runc
Default bridge
172.17.0.0/16, no names
CPU limit
--cpus=0.5 is 50 of 100 ms
Memory limit
none unless -m
Logs
no rotation by default
Stop
SIGTERM, 10 s, SIGKILL
Exit 137
SIGKILL, often memory
Hub pulls
100 or 200 in 6 hours
Volume prune
anonymous only; -a for named

Spot it when you see

  • Dependencies that conflict.
  • One build through all environments.
  • Many small services per host.
  • A whole stack on a laptop.

Tricks that stick

  • Seldom first, often last: order the Dockerfile.
  • See with namespaces, spend with cgroups.
  • A delete is a sticker over the file.
  • The socket is the crown: do not hand it out.

Do not forget

  • latest in production.
  • Secrets in layers.
  • Ports published to the world.
  • No limits, no log rotation.
  • A volume treated as a backup.