Running docker inside Kubernetes with containerd Running docker inside Kubernetes with containerd kubernetes kubernetes

Running docker inside Kubernetes with containerd


Disclaimer: as of this writing containerd didn't replace Docker, you can install containerd separately from Docker, and you can point the Kubernetes CRI to directly talk to the containerd socket.

So, when you install Docker it does install together with containerd and the Docker daemon talks to it. You'll see a process like this:

docker-containerd --config /var/run/docker/containerd/containerd.toml

However, the Docker client still talks to the Docker daemon, that's why when you run the Docker client in your container you still need to talk directly to the Docker daemon (/var/run/docker.sock), so you can switch back to /var/run/docker.sock and I believe it should work.


At least with MicroK8s 1.18 on Ubuntu 20.04, I found that a fix for this was to explicitly install Docker alongside Kubernetes.

Similar steps should apply to other Kubernetes distributions that don't include Docker.

After installing microk8s, you can do the following to install Docker:

# Shut down microk8ssudo snap disable microk8s# Assuming no Docker installed yet - this fixes the case  # where Kubernetes results in this path being a directory rm -rf /var/run/docker.socksudo apt-get install docker.iols -l /var/run/docker.sock# Output should show socket not directory:#    srw-rw---- 1 root docker 0 Aug  6 11:50 /var/run/docker.sock# (See https://docs.docker.com/engine/install/linux-postinstall/ for usermod + newgrp commands at this point) # Restart microk8s sudo snap enable microk8s

Other Kubernetes distributions may have a different way to shut down processes more selectively.

journalctl -xe is useful to see any errors from Docker or Kubernetes here.

In Kubernetes manifests, be sure to use /var/run/docker.sock as the host path when mounting docker.sock.

Related issues:

Post-install steps for Docker on Linux