Podman, Docker and containerd Compared: Container Engines and Runtimes

infra9 min한국어

#podman#docker#containerd#container-runtime#rootless

Assume you start the same nginx container in three ways.

docker run -d --name web nginx
nerdctl run -d --name web nginx   # CLI for containerd
podman run -d --name web nginx    # run as a regular user

nginx runs in all three cases, but the process trees differ.

# docker run
systemd
 ├─ dockerd
 ├─ containerd
 └─ containerd-shim-runc-v2
     └─ nginx

# nerdctl run
systemd
 ├─ containerd
 └─ containerd-shim-runc-v2
     └─ nginx

# podman run
systemd
 └─ conmon
     └─ nginx

The nginx started by Docker and by nerdctl both sit under containerd-shim-runc-v2.
The nginx started by Podman sits under conmon, with neither dockerd nor containerd anywhere.
Each tool covers a different part of running a container.

containerd-shim-runc-v2 is an intermediate process (a shim) that containerd starts for each container. It calls runc (the OCI runtime that actually creates the container using kernel features), then stays on as the container's parent process, handling its standard I/O and exit code. runc-v2 means it implements containerd's shim v2 interface with runc.

1. Docker, containerd and Podman

1.1 Docker: A Container Platform

Docker is a platform that bundles what you need to build, run and ship containers.
It provides the docker CLI, the dockerd daemon, image builds (BuildKit), and network and volume management.
Actually running containers is delegated internally to containerd.

1.2 containerd: A Container Runtime Daemon

containerd is a daemon that manages the container lifecycle: pulling and storing images, and creating, running and stopping containers.
It was split out of Docker and is a CNCF graduated project.
It is used less directly by people and more as a component called by higher-level systems such as Docker and Kubernetes.

1.3 Podman: A Daemonless Container Engine

Podman (Pod Manager) is a container engine that runs without a daemon.
The podman command calls the OCI runtime directly to run containers and does not use containerd.
Its CLI is nearly the same as Docker’s, so in many cases you can type podman where you would type docker.

NameKindWhat it coversWhere it is mostly used
Dockercontainer platformCLI, daemon, builds, networks, volumesdeveloper machines, single servers
containerdcontainer runtime daemonimage management, container lifecycleKubernetes nodes, inside Docker
Podmandaemonless container engineCLI, running containers, pods, builds (Buildah)RHEL-family servers, rootless use

2. How Containers Run: Engines, Runtimes and OCI

Running a container is split into several layers.

  • OCI runtime: configures the kernel’s namespaces and cgroups to start a single process as a container. runc and crun are the best known. It exits once the container is started.
  • Container runtime (high-level): pulls images, prepares the filesystem, calls the OCI runtime, and manages running containers. containerd and CRI-O belong here.
  • Engine and CLI: take user commands, tell the runtime what to do, and add features such as builds and networking. Docker and Podman belong here.

OCI (Open Container Initiative) is the standard that defines the image format (image spec) and runtime behavior (runtime spec).
All three tools use OCI images and start containers with an OCI runtime, so an image built with Docker runs on Podman or containerd.

Docker containerd Podman docker CLI dockerd containerd shim runc nerdctl, kubelet containerd shim runc podman conmon crun Linux kernel: namespaces, cgroups
All three start containers with an OCI runtime (runc, crun). Docker goes through containerd; Podman calls the OCI runtime directly.

3. Docker’s Execution Path

When you run docker run, the command travels down in this order.

  1. docker CLI: calls dockerd’s REST API over /var/run/docker.sock.
  2. dockerd: prepares the image, network and volumes, and asks containerd to create the container.
  3. containerd: starts a shim process (containerd-shim-runc-v2) for each container.
  4. shim: calls runc to create the container.
  5. runc: sets up namespaces and cgroups, starts nginx and exits. The shim remains as nginx’s parent process.
docker CLI runs commands dockerd root daemon containerd runtime daemon shim 1 per container nginx container runc starts, then exits creates docker CLI talks to dockerd over /var/run/docker.sock (REST API); dockerd talks to containerd over gRPC
The docker CLI asks dockerd, dockerd asks containerd, and containerd asks runc through a shim. runc exits after starting the container.

dockerd creates its containers in containerd’s moby namespace.
That is why containerd’s debugging tool can see containers created by Docker.

sudo ctr -n moby containers list

Since Docker Engine 29, fresh installs also store images in containerd’s image store.
Installations upgraded from earlier versions keep the previous storage (the overlay2 graph driver).

4. containerd’s Execution Path

Using containerd directly removes the dockerd step.
nerdctl or the Kubernetes kubelet sends requests straight to containerd, and everything below is the same as with Docker.

nerdctl kubelet containerd content store (images) snapshotter (overlayfs) CRI plugin CRI shim runc starts nginx ctr is for debugging; nerdctl is a Docker-style CLI
nerdctl and kubelet (CRI) send requests to containerd. containerd prepares the filesystem with its content store and snapshotter, and calls runc through a shim.

There are two CLIs for containerd.

CLIPurpose
ctrdebugging tool bundled with containerd
nerdctlCLI with Docker-style usage; a separate project

4.1 Shims and Snapshotters

  • shim: one process per container. It holds the container’s standard I/O and exit code, so containers keep running even when containerd restarts.
  • snapshotter: stacks image layers into the container’s root filesystem. On Linux it uses overlayfs by default.

overlayfs is a Linux filesystem that stacks several directories so they look like one. Image layers sit underneath as read-only, and anything the container changes is written only to the writable layer on top. So no matter how many containers start from the same image, its layers are stored on disk only once.

CRI (Container Runtime Interface) is the gRPC interface kubelet uses to call a container runtime.
containerd has a built-in CRI plugin, so kubelet calls containerd directly without Docker.
CRI-O is another runtime that implements CRI.

5. Podman’s Execution Path

When you run podman run, the command travels down in this order.

  1. podman: pulls the image and prepares the filesystem. Image and container data are stored on disk (containers/storage), not in a daemon.
  2. conmon: a monitor process, one per container. It calls the OCI runtime and holds the container’s I/O and exit code.
  3. crun or runc: starts the container and exits. Podman’s default OCI runtime is crun.
  4. podman exits: once the container is up, the podman command ends, leaving only conmon and nginx.
podman exits after run conmon 1 per container nginx container starts monitors crun starts, then exits no dockerd no containerd Image and container data stored on disk
podman starts conmon, and conmon calls crun to create the container. The podman command exits, leaving only conmon and the container.

5.1 No Daemon, and conmon

Docker’s shim and Podman’s conmon do the same job.
Both run one per container and handle the container’s I/O and exit code.
Docker has dockerd receiving every request, while Podman has no daemon.

  • Docker: every request goes through a single root dockerd. If dockerd stops, no new containers can be created.
  • Podman: each command starts a podman process that exits when done. Each user has their own storage and containers.

Since there is no daemon, starting containers at boot or restarting them is left to systemd.
For tools that need the Docker API, podman system service can open a Docker-compatible API socket.

5.2 Rootless: User Namespaces and UID Mapping

Rootless means running containers with regular user rights, without root.
Podman uses a user namespace to map UIDs inside the container to different UIDs on the host.

# /etc/subuid
alice:100000:65536
UID inside the containerUID on the host
0 (root)1000 (alice)
1 ~ 65536100000 ~ 165535

Root inside the container has only alice’s rights on the host.
Even if an attacker escapes the container, they cannot do anything on the host beyond what alice can.

Inside the container Host UID 0 root UID 1 ~ 65536 regular users such as nginx UID 1000 alice (the user who ran it) UID 100000 ~ 165535 /etc/subuid range user namespace Even after an escape, only alice's rights on the host
Root (UID 0) inside the container maps to alice (UID 1000) on the host; the other UIDs map to the range set in /etc/subuid.

Rootless has limits.

  • Ports: ports below 1024 cannot be bound with the default settings.
  • Networking: a regular user cannot create host network devices, so a user-space networking tool is used. Since Podman 5.0 the default is pasta; before that it was slirp4netns.
  • Storage: images are stored separately in the user’s home (~/.local/share/containers/storage). Each user pulls the same image separately.

5.3 Pods

Like a Kubernetes Pod, Podman can group several containers together.
Containers in the same pod share a network namespace and talk to each other over localhost.

podman pod create --name web -p 8080:80
podman run -d --pod web nginx
podman run -d --pod web my-exporter

You can export a pod definition as Kubernetes YAML (podman kube generate) or run a pod from Kubernetes YAML (podman kube play).

6. Permission Models Compared: Root Daemon, docker Group, Rootless

The Docker daemon runs as root by default.
That is why the Docker documentation warns about the docker group:

The docker group grants root-level privileges to the user.

A user in the docker group can mount the host’s / into a container and modify any host file.
Adding a user to the docker group is the same as giving that user root.

Docker (default)Docker rootless modePodman rootless
Daemondockerd running as rootdockerd running as the usernone
Container processesowned by rootowned by the userowned by the user
Who can use itdocker group = rootthat user onlythat user only
Setupdefaultseparate install and setupdefault

Docker also supports rootless mode, but it has to be set up separately.
Podman runs rootless from the start when run as a regular user.

Docker default Rootless (Podman, Docker rootless mode) alice docker group dockerd runs as root container owned by root alice regular user container owned by alice no daemon in between
In Docker's default setup, a docker group user starts root-owned containers through the root dockerd. In rootless mode, containers run with the rights of the user who started them.

7. Image Builds: BuildKit and Buildah

ToolHow it builds
Dockerdocker build. BuildKit is the default builder since Docker Engine 23.0
containerdno build feature. nerdctl build uses a separately running BuildKit (buildkitd)
Podmanpodman build, which uses Buildah internally

All three build from a Dockerfile (Podman also calls it a Containerfile), and the result is an OCI image.
An image built with any of them can be pushed to a registry and run with the others.

8. Use in Kubernetes

Kubernetes removed its Docker integration layer (dockershim) in 1.24, and kubelet now calls containerd or CRI-O directly through CRI.
Images built with Docker follow the OCI standard, so they run unchanged.
Podman does not implement CRI, so it is not used as a node runtime; it is used to try Kubernetes YAML locally (podman kube play).

9. Comparison and How to Choose

DockercontainerdPodman
Kindcontainer platformcontainer runtime daemondaemonless container engine
Daemondockerd + containerdcontainerdnone
Container monitor processcontainerd-shimcontainerd-shimconmon
Default OCI runtimeruncrunccrun
Default rightsroot daemonroot daemonthe user who ran it
Image buildsBuildKitnone (nerdctl + BuildKit)Buildah
CLIdockerctr, nerdctlpodman
Kubernetes node runtimeno built-in support since 1.24built-in CRInot applicable
  • When Docker fits: handling everything from build to run with one tool on a developer machine, or using Docker Compose and other Docker ecosystem tools as they are.
  • When containerd fits: when a higher-level system such as a Kubernetes node manages containers and you want a lightweight runtime.
  • When Podman fits: running containers per user without a root daemon, running containers as systemd services, or using RHEL-family servers.

References