Containers
A container shares the kernel that a virtual machine brings with it
A virtual machine carries its own OS. A container is a fenced-in process on a shared kernel.
Before Kubernetes, the container itself. Compare it with a virtual machine. Each virtual machine carries a whole guest operating system, on top of a hypervisor. That is heavy, and it is a strong wall. Containers have no operating system of their own. They share the one kernel of the host. So they are small, and they start like a process, because that is what they are. The price is a thinner wall.
Containers · Going deeper
Namespaces and cgroups
Namespaces isolate what a process sees. Cgroups limit what it uses.
Images
An image is read-only layers, and a container adds one thin layer
An image is immutable layers. Each container adds a writable layer that dies with it.
A container starts from an image. An image is a stack of read-only layers: the base files of a Linux distribution, then a language runtime, then your application. It is built once and never changed. Start two containers from it, and both share the same layers. Each gets one thin writable layer of its own on top. Delete the container and that layer is gone. Anything that must survive belongs in a volume.
Images · Going deeper
Dockerfile instructions
FROM a base, COPY and RUN to build, ENTRYPOINT and CMD to start.
Check yourself
Which stack is a container host?
Runtimes
The kubelet asks a runtime, and the runtime asks runc
kubelet to containerd over CRI, and containerd to runc by the OCI standard.
Who actually starts a container in a cluster? Follow the chain. The kubelet wants a pod's containers running. It does not start them itself. It asks a high-level runtime, usually container D, or cry O. That runtime pulls the image and manages the containers. It hands the final step to a low-level runtime, run C, which sets up the namespaces and control groups. The result is a Linux process running your code. The two links have names. The kubelet speaks C R I, the Container Runtime Interface. The runtimes follow O C I, the Open Container Initiative standard.
Runtimes · Going deeper
Runtimes compared
containerd and CRI-O are high-level. runc is low-level. gVisor and Kata sandbox.
Standards
Three OCI standards let you swap any tool for another
The OCI image, distribution and runtime specs make build tools, registries and runtimes interchangeable.
That standard is what makes containers portable. An image passes through three stages. It is built, with Docker, Podman, Buildah or kaniko. It is stored and shared in a registry: Docker Hub, the GitHub registry, Harbor, Quay. And it is run, by container D or cry O. Under each stage sits an open standard. The image spec says what an image is. The distribution spec says how to push and pull one. The runtime spec says how to run it. So any builder works with any registry and any runtime.
Standards · Going deeper
Registries and build tools
A registry holds repositories. Harbor is one you host yourself.
Check yourself
Which interface belongs at the "?"
Image names
A tag can move. A digest cannot
Name an image by registry, repository and tag. Only the digest is fixed.
Finally, how an image is named. First the registry: where it lives. Then the repository: which image. Then the tag: a label for a version. And every image has a digest, a fingerprint computed from its content. Here is why the difference matters. On Monday, the tag latest points to one digest. On Friday, someone pushes a new build, and latest points to another. The same name, a different image. A digest can never do that.
Image names · Going deeper · 1 of 2
Pulling images
imagePullPolicy, pull secrets, and what ImagePullBackOff means.
Image names · Going deeper · 2 of 2
Clue words for containerization
CRI for runtimes, OCI for the standards, digest for certainty.
Check yourself
What does the drawing show?
Lesson complete
You finished “Containerization”
Answer the questions along the way to see your score here.