Skip to content
LF Cert Trainer

Lesson 6 · Section 2: Core Concepts

Lesson 6: A note on Docker deprecation: what was removed, and what was not

Kubernetes v1.24 removed dockershim, not Docker. See what dockershim was, why it went, what keeps working, what breaks, and how to check and debug a node's runtime without the docker command. · 14 min read · 4 min video

1/11A note on Docker deprecation
0:00 / 4:24

Narrated by the local narrator voice. Keys: Space plays and pauses, J and L step, C captions, F full screen.

Why this note exists

In December 2020 the Kubernetes v1.20 release notes carried one line that travelled much further than its authors expected: "Docker support in the kubelet is now deprecated and will be removed in a future release." Many people read it as "Kubernetes is dropping Docker" and worried about their images, their Dockerfiles and their clusters.

What was deprecated, and then removed in v1.24 (May 2022), was something much smaller: dockershim, a piece of adapter code inside the kubelet. Nothing about how you build or ship images changed. What changed is which program the kubelet talks to on each node, and which commands you use when you log in to a node.

Older tutorials, blog posts and course videos still show docker ps on a Kubernetes node. This lesson explains why that no longer works, so the rest of the course (and the exam's clusters) make sense.

What dockershim was

To understand the adapter you need three terms:

TermWhat it is
CRI (Container Runtime Interface)The gRPC API the kubelet uses to tell a runtime "pull this image, create this Pod sandbox, start this container". Introduced in Kubernetes v1.5 so that the kubelet would not need code for each runtime
Docker Engine (dockerd)The daemon behind the docker command. It predates CRI and never implemented it. It has its own API, made for people and tools, not for an orchestrator
dockershimCode compiled into the kubelet that accepted CRI calls and translated them into Docker API calls. The only runtime adapter that lived inside Kubernetes itself
Starting one container, before and after v1.24CRIDocker APICRIkubeletv1.23 and olderdockershiminside the kubeletDocker Enginedockerdcontainerdruncstarts the containerkubeletv1.24 and newercontainerdCRI plugin built inruncstarts the container
Starting one container, before and after v1.24. Dockershim translated the kubelet's CRI calls into Docker API calls. Docker Engine then asked containerd anyway. Talking to containerd directly removes two hops and the code the kubelet had to carry.

Parts:

  • kubelet (v1.23 and older)
  • dockershim (inside the kubelet)
  • Docker Engine (dockerd)
  • containerd
  • runc (starts the container)
  • kubelet (v1.24 and newer)
  • containerd (CRI plugin built in)
  • runc (starts the container)

Connections:

  • kubelet to dockershim: CRI
  • dockershim to Docker Engine: Docker API
  • Docker Engine to containerd
  • containerd to runc
  • kubelet to containerd: CRI
  • containerd to runc

The top row is how every Docker-based cluster worked up to v1.23. Notice what sits at the far end of it: containerd. Docker Engine has not run containers itself for years. Docker split its low-level runtime out as containerd in 2016 and donated it to the CNCF, and dockerd has used it ever since. So the kubelet was calling an adapter, which called Docker, which called the component that could have done the job directly.

The bottom row is every cluster since v1.24: containerd ships with a CRI plugin, so the kubelet talks to it without a translator. The container that starts is the same in both rows, created by the same runc.

Why it was removed

  • It was vendor code in the kubelet. Every other runtime implements CRI on its own side. Dockershim was Kubernetes maintainers keeping up with another project's API, release after release. The deprecation notice itself said it "has seen maintenance issues in the Kubernetes community".
  • Docker Engine does more than Kubernetes needs. Its own networking, volumes, build system and Swarm mode are unused on a node. Kubernetes brings CNI for networking and CSI for storage. Fewer moving parts means fewer things to break and patch.
  • New features were built on CRI only. Work such as cgroup v2 support and user namespaces targets CRI runtimes. Each one would have needed extra work in dockershim, or would simply not have reached Docker nodes.
  • The shorter path is cheaper. Two fewer hops per operation, and one fewer daemon whose restart can disturb the node.
Under the hood · The timeline, release by release
  • v1.5 (December 2016): CRI arrives in alpha. Docker support inside the kubelet is rewritten as the first CRI implementation: that is dockershim.
  • 2017 to 2019: containerd gains a CRI plugin (built in from containerd 1.1), CRI-O matures, and managed platforms start moving their nodes to containerd.
  • v1.20 (December 2020): dockershim is deprecated. The blog post "Don't Panic: Kubernetes and Docker" is published the same week.
  • v1.24 (May 2022): dockershim is removed. The kubelet flags that only made sense with it go too: --network-plugin, --cni-conf-dir and --cni-bin-dir (CNI is now configured in the runtime).
  • v1.27: the already meaningless --container-runtime kubelet flag is removed. An old kubelet unit file that still passes --container-runtime=remote now stops the kubelet from starting: a classic upgrade failure.
  • Meanwhile: Mirantis and Docker took the dockershim code out of the tree and maintain it as the separate project cri-dockerd.

What still works, and what does not

Why your images did not changebuildspushpullrunsdocker buildlaptop or CIOCI imagelayers + configRegistryDocker Hub, GHCR, ...containerdon the nodePodrunning container
Why your images did not change. docker build produces an image in the OCI format. Every runtime pulls and runs that same format, so the tool that built the image does not matter to the cluster.

Parts:

  • docker build (laptop or CI)
  • OCI image (layers + config)
  • Registry (Docker Hub, GHCR, ...)
  • containerd (on the node)
  • Pod (running container)

Connections:

  • docker build to OCI image: builds
  • OCI image to Registry: push
  • Registry to containerd: pull
  • containerd to Pod: runs

"Docker image" is a habit of speech. What docker build produces is an image in the OCI (Open Container Initiative) format, and every runtime pulls and runs that format. That is why nothing changed for developers.

You do thisAfter dockershim's removal
Build images with docker build on a laptop or in CIWorks. The cluster never knew how the image was built
Pull from Docker Hub or any other registryWorks. Registries serve OCI images to any runtime
Use Docker Desktop, kind or minikube locallyWorks. kind and minikube run nodes as Docker containers, and inside each node the runtime is containerd
Run docker ps on a node to see Pods' containersBreaks. Docker is not installed, or is installed and shows nothing (see below)
Mount /var/run/docker.sock into a Pod (CI build jobs, some monitoring and security agents)Breaks. No socket. Build with a daemonless tool such as BuildKit, Kaniko or Buildah, and update agents to versions that use CRI
Build an image on the node and run it with imagePullPolicy: NeverBreaks. The kubelet only sees images in the CRI runtime's store
Configure registry mirrors or insecure registries in /etc/docker/daemon.jsonIgnored. Configure them in the runtime instead (for containerd, /etc/containerd/config.toml and /etc/containerd/certs.d/)
Under the hood · Docker is installed on the node, yet docker ps is empty. Why?

containerd keeps its containers and images in namespaces (containerd's own, unrelated to Kubernetes namespaces). The kubelet's CRI plugin works in the namespace k8s.io; Docker Engine works in moby. Both can share one containerd daemon on the same machine and never see each other's containers or images.

sudo ctr namespaces list              # k8s.io, and moby if Docker is installed
sudo ctr -n k8s.io containers list    # the kubelet's containers
sudo ctr -n k8s.io images import app.tar   # make a locally built image visible to the kubelet

That is also the reason an image you just built with docker build on a node gives ErrImageNeverPull or ImagePullBackOff: it is in the wrong store. Push it to a registry, or import it into k8s.io.

Your choices today

What a kubelet can talk to todayDocker APIkubeletCRIgRPC over a socketcontainerdmost clustersCRI-OOpenShift and otherscri-dockerdexternal adapterDocker Enginedockerd
What a kubelet can talk to today. The kubelet speaks only CRI, over a Unix socket. Anything that answers CRI on that socket can be the runtime. Docker Engine does not, so it needs the external adapter cri-dockerd.

Parts:

  • kubelet
  • CRI (gRPC over a socket)
  • containerd (most clusters)
  • CRI-O (OpenShift and others)
  • cri-dockerd (external adapter)
  • Docker Engine (dockerd)

Connections:

  • kubelet to CRI
  • CRI to containerd
  • CRI to CRI-O
  • CRI to cri-dockerd
  • cri-dockerd to Docker Engine: Docker API

The kubelet finds its runtime through one setting, the runtime endpoint: a Unix socket. Whatever answers CRI on that socket is the node's runtime.

RuntimeSocketNotes
containerdunix:///run/containerd/containerd.sockThe default choice for kubeadm clusters and most managed services
CRI-Ounix:///var/run/crio/crio.sockBuilt only for Kubernetes; the runtime of OpenShift
Docker Engine + cri-dockerdunix:///var/run/cri-dockerd.sockFor nodes that must keep Docker Engine. Both the Docker daemon and the adapter have to be installed and running

kubeadm detects the socket by itself when only one runtime is installed. With several (for example Docker Engine plus cri-dockerd on a machine that also has containerd, which is always the case with Docker), it stops and asks you to choose: pass --cri-socket unix:///var/run/cri-dockerd.sock to kubeadm init or kubeadm join.

Using it

Example · Find out which runtime a node uses

From anywhere with kubectl:

kubectl get nodes -o wide          # last column: CONTAINER-RUNTIME
kubectl get node node-1 -o jsonpath='{.status.nodeInfo.containerRuntimeVersion}{"\n"}'
containerd://2.1.4

The prefix is the runtime: containerd://, cri-o://, or docker:// on a node that uses cri-dockerd.

On the node itself, find the socket the kubelet was told to use. It is either the flag --container-runtime-endpoint or the field containerRuntimeEndpoint in the kubelet's configuration file:

ps -ef | grep [k]ubelet | tr ' ' '\n' | grep runtime
sudo grep -ri runtime /var/lib/kubelet/

Example · Debug a control plane that kubectl cannot reach

kubectl get nodes answers "connection refused": the API server is down, so kubectl cannot tell you why. On a kubeadm cluster the API server is a static Pod, which means its container is run by the kubelet through the runtime. SSH to the control plane node and ask the runtime directly:

sudo crictl ps -a --name kube-apiserver     # -a also shows exited containers
sudo crictl logs --tail=20 <container-id>   # why did it exit?
sudo crictl pods --name kube-apiserver      # does the Pod sandbox exist at all?
journalctl -u kubelet --since "10 min ago"  # if there is no container, the kubelet says why

With Docker this used to be docker ps -a | grep apiserver and docker logs. The reasoning is the same; only the tool changed.

Example · Translate an old Docker habit

crictl deliberately keeps Docker's subcommand names for everything it supports:

With DockerWith any CRI runtime
docker ps -acrictl ps -a
docker imagescrictl images
docker logs -f <id>crictl logs -f <id>
docker exec -it <id> shcrictl exec -it <id> sh
docker inspect <id>crictl inspect <id> (containers), crictl inspectp <id> (Pods)
docker pull nginxcrictl pull nginx
docker statscrictl stats
(nothing)crictl pods: list Pod sandboxes
docker build, docker push, docker runNot in crictl. It is a debugging tool: create workloads with kubectl

Tricks

Common mistakes

  • Saying "Kubernetes no longer supports Docker images". It does. The image format is OCI and was never the issue.
  • Looking for containers with docker ps on a node. Empty output does not mean nothing is running. Use crictl ps.
  • Building an image on the node and expecting Pods to find it. The kubelet only sees the CRI runtime's image store. Push to a registry, or import with ctr -n k8s.io images import.
  • Installing Docker Engine and forgetting cri-dockerd. From v1.24 the kubelet cannot use Docker Engine on its own; kubeadm init finds no usable CRI socket, or finds containerd with its CRI plugin disabled.
  • Keeping removed kubelet flags through an upgrade. --container-runtime and --network-plugin in an old unit file or /var/lib/kubelet/kubeadm-flags.env make a newer kubelet exit at start. journalctl -u kubelet shows "unknown flag".
  • Confusing CRI with OCI. CRI is how the kubelet talks to a runtime. OCI is the format of images and the low-level contract for running a container. Docker fails the first and fully meets the second.

Recap

  • v1.20 deprecated and v1.24 removed dockershim, the kubelet's built-in adapter for Docker Engine. Docker itself was not removed from anything.
  • Images built with Docker are OCI images and run on every runtime.
  • The kubelet speaks only CRI, over a socket: containerd or CRI-O directly, Docker Engine only through cri-dockerd.
  • Check a node's runtime with kubectl get nodes -o wide.
  • On a node, use crictl (ps, pods, logs, images) where older guides say docker.

Official docs

Quiz: check what you learned

5 questions on this lesson · about 3 min · instant feedback. Missed questions come back in your review queue.

Sign in to take the quiz and keep your score.

Practise: try it on a real cluster

A hands-on lab for this lesson. You get goals, not steps: any solution that reaches them passes.

  • Ask the container runtime on a node directly with crictl: find the process behind a container, read the logs of a container that already exited, and remove an image from one node only.

    Investigate · Level 2 · standard · target 20 min

Discussion

Learners ask and answer questions here. Sign in to read and join the discussion.