Keep Docker Engine as Your Kubernetes Runtime on Ubuntu with cri-dockerd
Sometimes you genuinely want Docker Engine as the Kubernetes node runtime — a team standardized on the Docker CLI/API for tooling, an image-build box that doubles as a node, or a legacy playbook you can't rewrite yet. Since dockershim was removed in Kubernetes 1.24, that path now runs through cri-dockerd , an open-source CRI adapter maintained by Mirantis. Here's how to set it up on Ubuntu, and…
This guide explains how to utilize Docker Engine as the Kubernetes node runtime on Ubuntu using cri-dockerd. The need for this setup arises from various factors, such as teams preferring the Docker CLI/API, an image-build box acting as a node, or legacy playbooks that cannot be rewritten yet. Since dockershim was discontinued in Kubernetes 1.24, the pathway now involves cri-dockerd, an open-source CRI adapter maintained by Mirantis.
The first step is installing Docker Engine on Ubuntu, which should be done using Docker's official repository instead of the docker.io package to ensure the latest engine version is obtained. This process involves updating apt-get, installing necessary certificates, and adding Docker's GPG key to the keyring. After that, the Docker repository is added, and Docker Engine and its dependencies (including containerd.io) are installed, followed by setting the cgroup driver to systemd, restarting Docker, and enabling the service.
Next, download and install the latest version of cri-dockerd corresponding to the architecture of the Ubuntu system. After installing cri-dockerd, enable the service and note the CRI socket. Then, point kubeadm at the cri-dockerd socket by initiating an init process with specified flags, including the path to the CRI socket. This process remains consistent with the setup for containerd, except for the CRI endpoint. Worker nodes must also use the same flag during the kubeadm join command.
Finally, verify the Kubernetes node status by executing `kubectl get nodes -o wide`, which should display "docker://" followed by the engine version. However, it is crucial to note that using cri-dockerd means images pulled by the kubelet and images pulled using docker pull will coexist in the same storage. This may lead to confusion between Docker-managed and Kubernetes-managed containers.
To avoid accidentally removing containers managed by the kubelet, it's recommended to use crictl (CRI-aware) for managing cluster containers and reserve docker for managing manually pulled images.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.