Containers in Kubernetes terms
An image is content-addressed layers plus a manifest, and a container is a process the kubelet asks a CRI runtime to start. This is the part of the container toolchain a pod spec controls.
Shows the lesson one block at a time. Arrow keys step, number keys jump to a scene, and Escape returns to the page where you were.
Kubernetes never builds an image and never runs a container itself. It stores a pod spec that names an image, and the kubeletThe agent on every node that turns pod specs into running containers and reports their status. on the chosen node asks a container runtime to pull that image and start a process from it. This lesson covers both halves of that handoff: what an image is, and what the runtime does with it.
Reconcile, in 6 scenes
Images are layers plus a manifest
An OCI imageA container image in the Open Container Initiative format: filesystem layers, a config blob and a manifest that lists them by digest. is not one file. It is a set of blobs in a registry, each named by the SHA-256 of its content:
- Layers are tar archives of filesystem changes. The runtime stacks them in order to build the container’s root filesystem.
- The config is a JSON document holding the default
ENTRYPOINT,CMD, environment, working directory and user, the target platform, and the ordered digests of the uncompressed layers (diff IDs). - The manifest lists the config and the layers by digest, size and media type.
- An image index points at one manifest per platform, so
linux/amd64andlinux/arm64nodes pull different layers under the same name.
Because every reference is a content hash, a node never downloads a layer it already holds, and images built on the same base share those layers on disk. On a node, containerd unpacks layers through a snapshotter, overlayfs by default. Docker Engine’s storage drivers matter only on a Docker host: aufs was removed in Docker Engine 24 and devicemapper in Docker Engine 25, and fresh installs of Docker Engine 29 use the containerd image store.
Tags, digests and pull policy
A reference has up to four parts: registry/repository:tag@digest. Leave out the registry and Docker Hub is assumed; leave out the tag and latest is assumed, so nginx means docker.io/library/nginx:latest. The latest tag is a name like any other. It does not mean newest.
A tag is a mutable pointer: anyone who can push to the repository can move myapp:v2 to different content tomorrow. A digestThe SHA-256 of an image manifest or index, written sha256:…. It names exactly one image and cannot be repointed. cannot move. The manifest lists the config and layer digests, so pinning the manifest pins every byte. When a reference carries both a tag and a digest, only the digest is used for the pull.
imagePullPolicy decides when the kubelet contacts the registry:
| Policy | Behaviour |
|---|---|
IfNotPresent | Pull only when the node has no copy of the image. |
Always | Resolve the reference against the registry each time a container starts; layers download only when the digest has changed. |
Never | Use the node’s copy or fail. |
Leave the field out and the API server fills it in when the object is created: Always for a :latest tag or no tag, IfNotPresent for any other tag or for a digest. Here nginx:1.30 names nginx’s stable branch, while latest follows the mainline branch, 1.31. The container status records which digest the tag resolved to:
kubectl get pods pinned floating -o custom-columns=NAME:.metadata.name,IMAGE:.spec.containers[0].image,POLICY:.spec.containers[0].imagePullPolicy
NAME IMAGE POLICY pinned nginx:1.30 IfNotPresent floating nginx Always
kubectl get pod pinned -o jsonpath='{.status.containerStatuses[0].imageID}'
docker.io/library/nginx@sha256:5d1c5d5e53f3850eff3c6c4beb506a3dca2a50721d26f05e6971ccc709fb7afd
ENTRYPOINT and CMD become command and args
The image config carries a default executable (ENTRYPOINT) and default arguments (CMD). In a container spec, command replaces ENTRYPOINT and args replaces CMD:
| The container spec sets | The process that runs |
|---|---|
| neither | image ENTRYPOINT followed by image CMD |
args only | image ENTRYPOINT followed by your args |
command only | your command; the image CMD is dropped |
| both | your command followed by your args |
The third row is the trap. Setting command alone discards the image’s default arguments, and putting a flag in command makes the runtime try to execute the flag. The simulator’s ghcr.io/kx-labs/web image has ENTRYPOINT ["/usr/local/bin/web"]; this pod meant to change its port:
apiVersion: v1
kind: Pod
metadata:
name: wrong-command
spec:
containers:
- name: web
image: ghcr.io/kx-labs/web:1.1
command: ["--port=9090"]
kubectl get pod wrong-command
NAME READY STATUS RESTARTS AGE wrong-command 0/1 CrashLoopBackOff 2 (15s ago) 30s
kubectl get pod wrong-command -o jsonpath='{.status.containerStatuses[0].lastState.terminated.message}'
failed to create containerd task: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: exec: "--port=9090": executable file not found in $PATH: unknown
The message names every layer of the stack: containerd, its shim, then runc failing to exec the string --port=9090. The fix is args: ["--port=9090"].
Two Dockerfile rules decide what the defaults are. An image that does not set ENTRYPOINT inherits its base image’s, and setting ENTRYPOINT clears any CMD inherited from the base. Write both in exec form (["/web", "--port=8080"]) so the binary is PID 1 and receives SIGTERM; shell form wraps it in /bin/sh -c, which does not forward the signal, so the pod sits out its whole grace period before SIGKILL.
Building images for a cluster
BuildKit is the default builder for Docker Desktop and Docker Engine. Some of what a Dockerfile says, Kubernetes reads from the image config, and some it ignores:
| Dockerfile instruction | What Kubernetes does with it |
|---|---|
RUN, COPY, ADD | Create filesystem layers. WORKDIR adds one only when it creates a directory; ENV, CMD, EXPOSE and the rest change only the config. |
ENV KEY=value | Becomes default environment; env in the pod spec wins on conflict. The space-separated ENV KEY value form is deprecated. |
USER 10001 | Becomes the default user. runAsNonRoot: true can verify only a numeric user. |
EXPOSE 8080 | Not used. It documents the port for docker run -P and publishes nothing; containerPort in a pod spec is informational too. |
HEALTHCHECK | Not used. Docker and Swarm run it; the kubelet runs only the liveness, readiness and startup probes in the pod spec. |
A multi-stage build compiles in one stage and copies only the result into a minimal final stage, which cuts pull time and leaves no shell or package manager for an attacker. ARG is the only instruction allowed before FROM.
# syntax=docker/dockerfile:1
FROM golang:1.27 AS build
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 go build -o /out/web ./cmd/web
FROM gcr.io/distroless/static-debian13:nonroot
COPY --from=build /out/web /web
USER 65532:65532
ENTRYPOINT ["/web"]
CMD ["--port=8080"]
A numeric non-root USER matters more than it looks: without user namespaces, root in a container is UID 0 on the host, held back only by capabilities, seccomp and Linux security modules. Pods opt in to user namespaces with hostUsers: false, GA in Kubernetes 1.36 and off unless a pod sets it.
From kubelet to process
The kubelet does not talk to Docker. It speaks the CRIContainer Runtime Interface: the gRPC API the kubelet uses to ask a runtime to pull images and create pod sandboxes and containers. to a runtime, usually containerd or CRI-O. Kubernetes 1.36 and later need containerd 2.0 or later. For each pod the runtime creates a sandbox that holds the pod’s shared network namespace, then for each container it unpacks the image and hands an OCI runtime spec to runc (or crun), which creates the process in its namespaces and cgroups. From Kubernetes 1.35 the kubelet refuses to start on a cgroup v1 node unless failCgroupV1: false is set.
Registries and credentials
The node pulls the image, not your laptop, so docker login on your machine means nothing to the cluster. A node authenticates with an imagePullSecrets entry on the pod (a kubernetes.io/dockerconfigjson Secret) or with a kubelet credential provider plugin that fetches short-lived registry tokens. Both a missing credential and a tag that was never pushed look the same at first glance:
kubectl get pod typo
NAME READY STATUS RESTARTS AGE typo 0/1 ImagePullBackOff 0 30s
kubectl get events --field-selector involvedObject.name=typo
LAST SEEN TYPE REASON OBJECT MESSAGE 30s Normal Scheduled pod/typo Successfully assigned default/typo to kx-worker3 18s Normal Pulling pod/typo Pulling image "nginx:1.300" 17s Warning Failed pod/typo Failed to pull image "nginx:1.300": rpc error: code = NotFound desc = failed to pull and unpack image "docker.io/library/nginx:1.300": failed to resolve reference "docker.io/library/nginx:1.300": docker.io/library/nginx:1.300: not found 17s Warning Failed pod/typo Error: ErrImagePull 16s Normal BackOff pod/typo Back-off pulling image "nginx:1.300" 16s Warning Failed pod/typo Error: ImagePullBackOff
ErrImagePull is one failed attempt; ImagePullBackOff means the kubelet is waiting before the next one, raising the delay each time up to a five-minute cap. The Failed event carries the reason: not found for a wrong tag, an authorization error such as 401 Unauthorized or pull access denied for credentials, and toomanyrequests when a registry rate-limits the node. In November 2026 Docker Hub allowed unauthenticated clients 100 pulls per 6 hours per IPv4 address or IPv6 /64, and personal accounts 200, so a busy cluster pulling anonymously through one NAT address hits that limit. The bad-tag-rollout incident is this failure in the middle of a Deployment rollout.
kubectl --context kind-kx run untagged --image=nginxkubectl --context kind-kx run stable --image=nginx:1.30kubectl --context kind-kx get pods untagged stable -o custom-columns=NAME:.metadata.name,POLICY:.spec.containers[0].imagePullPolicy,DIGEST:.status.containerStatuses[0].imageIDkubectl --context kind-kx run missing-tag --image=nginx:1.300kubectl --context kind-kx get events --field-selector involvedObject.name=missing-tagkubectl --context kind-kx delete pod untagged stable missing-tag
For your own kind cluster kx: copy a command and paste it into your terminal. Run in the simulator runs the same command in this page's simulated cluster instead; nothing on this page touches your machine. The untagged pod gets Always and the stable pod IfNotPresent; missing-tag reaches ImagePullBackOff with a not found event.
Actual state
Check your understanding
Your first answer to each check is the one that counts. After a miss you can answer again; passing every check reconciles the lesson.
Lesson not yet reconciled
Desired: 4 objectives, 0 metReconciled: 4 of 4 objectives met
- Explain what an OCI image is, in terms of content-addressed layers, a config and a manifest. (not yet met)
- Map Dockerfile ENTRYPOINT and CMD onto a container's command and args. (not yet met)
- Say why a tag is a mutable pointer and a digest is not, and choose one for a manifest. (not yet met)
- Name the pieces between the kubelet and a running process, namely CRI, containerd and runc. (not yet met)
Pass every check above to reconcile this lesson.
Every check has passed, so the desired state is met. First-try accuracy: 0 of 5. This lesson's review cards are in your queue.
Practice
Put this lesson to work on the simulated cluster. Everything runs in your browser, with nothing to install.
Changed since the notes
This lesson draws on an earlier set of study notes. Where the documentation contradicts a claim in them, qualifies it or has moved past it, the claim is listed here with the corrected statement and the source it was checked against.
Show 16 corrections
The notes saidDropping Docker support just removed the shim so Kubernetes talks directly to containerd (two entries)
Correcteddockershim was deprecated in v1.20 and removed in v1.24. The kubelet talks CRI to any CRI runtime, such as containerd or CRI-O. Docker Engine works only through the external cri-dockerd adapter maintained by Mirantis.
The notes saidIn modern Linux systems, cgroups v2 provides a unified hierarchy
CorrectedTrue. Kubernetes context: from v1.35 the kubelet refuses to start on cgroup v1 unless
failCgroupV1: falseis set. On EKS, AL2023 uses cgroup v2; Bottlerocket 1.35 uses v2 but sets failCgroupV1: false; Fargate still uses v1. Removal of the v1 fallback (KEP-5573) is placed at v1.38 only by secondary sources and is unconfirmed.Sourcekubernetes.io/blog/2026/10/06/kubernetes-cgroups-v2-shift
The notes saidUser namespace: a process can be root inside its namespace but unprivileged on the host
CorrectedTrue for the kernel feature. Kubernetes pod user namespaces (
hostUsers: false) are GA in v1.36 and remain opt-in per Pod.Sourcekubernetes.io/blog/2026/04/23/kubernetes-v1-36-userns-ga
The notes saidImplies user namespaces are part of normal container isolation
CorrectedThey are off by default. Docker userns-remap is a daemon-level opt-in, and Kubernetes needs
hostUsers: falseon each Pod (GA in v1.36). Without them, root in a container is host UID 0, limited by capabilities, seccomp and LSMs.The notes saidoverlay2 is the default; aufs, btrfs and devicemapper are available
Correctedaufs was removed in Docker Engine v24.0 and devicemapper in v25.0. Fresh installs of Docker Engine 29.0+ default to the containerd image store (snapshotters). Upgraded hosts keep overlay2 until switched.
The notes saidDocker Hub provides free public repositories and paid private repositories
CorrectedPlans change. Pull limits: unauthenticated users get 100 pulls per 6 hours per IPv4 address or IPv6 /64, Personal accounts 200 per 6 hours, and Pro/Team/Business are unlimited under fair use. Hitting a limit gives
toomanyrequestsand ImagePullBackOff. Per-plan private-repo allowances were not re-verified.The notes saidnginx:1.21 / nginx:1.21.6 examples
Corrected1.21 is a 2021 mainline branch. The current stable branch is 1.30 (first released 2026-04-14) and mainline is 1.31.
Sourcenginx.org/2026.html
The notes saidDigest is a hash of the image configuration and layers
CorrectedThe digest is the SHA-256 of the image manifest, or of the image index for multi-platform images. The manifest lists the config and layer digests, so the digest covers them indirectly.
Sourcegithub.com/opencontainers/image-spec/blob/v1.0/manifest.md
The notes saidFROM ubuntu:22.04, python:3.11-slim, golang:1.21
CorrectedCurrent versions are Ubuntu 26.04 LTS (2026-04-23), Python 3.15 (2026-10-09) and Go 1.27 (2026-08-19). Go 1.25 is no longer supported.
Sourcego.dev/doc/go1.27
The notes saidBuildKit, Docker's modern build backend
CorrectedBuildKit is the default builder for Docker Desktop and Docker Engine users. The current page does not name the Engine version where it became the default.
The notes saidThe older syntax ENV MY_VAR value is still supported
CorrectedIt is supported for backward compatibility but deprecated. The LegacyKeyValueFormat build check warns about it, and the Dockerfile reference says it may be removed in a future release. Use
ENV KEY=value.Sourcedocs.docker.com/reference/build-checks/legacy-key-value-format
The notes saidEach instruction in the Dockerfile creates a layer
CorrectedOnly instructions that change files create layers: RUN, COPY, ADD, and WORKDIR when it creates a directory. EXPOSE, CMD, ENV and similar only set image metadata.
Sourcedocs.docker.com/get-started/docker-concepts/building-images/understanding-image-layers
The notes saidEvery Dockerfile must start with a FROM instruction
CorrectedFROM can come after parser directives, comments and global ARGs. ARG is the only instruction allowed before FROM.
The notes saidIf you don't specify ENTRYPOINT, it defaults to an empty value
CorrectedIf you don't set ENTRYPOINT, the image inherits the base image's ENTRYPOINT. Setting ENTRYPOINT clears an inherited CMD.
The notes saidHEALTHCHECK is used by orchestrators
CorrectedDocker and Swarm use HEALTHCHECK. Kubernetes uses the liveness, readiness and startup probes in the Pod spec (exec, grpc, httpGet, tcpSocket). I found no primary Kubernetes page that says outright that HEALTHCHECK is ignored.
The notes saidEXPOSE is used by some orchestration systems for networking
CorrectedEXPOSE does not publish a port. It documents the port and is used by
docker run -P. Kubernetes does not use it, and containerPort is informational too.
Every correction across the guide, by note and topic.
Sources
Checked against kubernetes.io, OCI image-spec and Docker documentation for Kubernetes 1.37 on .
- kubernetes.io/docs/concepts/containers/images
- kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container
- kubernetes.io/docs/concepts/containers/cri
- kubernetes.io/docs/setup/production-environment/container-runtimes
- kubernetes.io/docs/tasks/administer-cluster/migrating-from-dockershim
- kubernetes.io/docs/tasks/administer-cluster/kubelet-credential-provider
- github.com/opencontainers/image-spec/blob/main/manifest.md
- github.com/opencontainers/image-spec/blob/main/image-index.md
- docs.docker.com/reference/dockerfile
- docs.docker.com/build/building/multi-stage
- docs.docker.com/build/buildkit
- docs.docker.com/engine/storage/containerd
- docs.docker.com/docker-hub/usage
Containers in Kubernetes terms
↓ ↑ step, 1 to 6 scene, Esc leave