keepcalculator

06 Numbers and Powers

Podman vs Docker Rootless Containers

Card No. 06·86756 · Updated · Standard formula, shown below

Podman and Docker both support rootless containers, but they differ in architecture, security model, and workflow. This article explains the key differences, how rootless mode works in each, and which one might fit your needs.

Background: What Are Rootless Containers?

Rootless containers run without the root user having to start the container engine or the container processes. In traditional Docker, the daemon runs as root, and containers are spawned by that root process. Rootless mode shifts the user namespace mapping so that the container’s root user is mapped to an unprivileged user on the host. This reduces the impact of a container escape because the container processes run with the privileges of a regular user, not root.

Both Podman and Docker offer rootless operation, but they implement it differently. Docker uses a daemon (dockerd) that can run in rootless mode with the help of rootlesskit. Podman is daemonless by design and uses fuse-overlayfs or the native slirp4netns for networking.

How Rootless Mode Works in Docker

Docker’s rootless mode was introduced experimentally and became stable in Docker Engine 19.03. It runs the Docker daemon inside a user namespace, using rootlesskit to create a network namespace and mount namespace. The daemon itself runs as an unprivileged user, and containers are launched as child processes of that user.

Key components:

  • rootlesskit – sets up user, mount, and network namespaces.
  • slirp4netns – provides user-mode networking (NAT) for containers.
  • fuse-overlayfs – used for storage driver when native overlayfs is not available.

To enable rootless mode, you install Docker, then run dockerd-rootless.sh as a non-root user. The daemon listens on a socket in the user’s home directory (/run/user/1000/docker.sock). You then set DOCKER_HOST=unix:///run/user/1000/docker.sock to communicate with it.

How Rootless Mode Works in Podman

Podman is designed to be daemonless. It uses conmon to manage containers and crun or runc as the OCI runtime. When run as a non-root user, Podman automatically creates a user namespace and maps the container’s root user to the invoking user. No separate daemon is needed; each Podman command talks directly to the runtime.

Networking in rootless Podman uses slirp4netns (or optionally pasta for better performance). Storage uses fuse-overlayfs or the native vfs driver. Podman also supports rootless containers with the --userns=keep-id flag to map the container user to the host user’s UID/GID.

Key Differences: Daemon vs Daemonless

The most significant difference is the presence of a daemon. Docker’s rootless mode still runs a daemon (dockerd) as an unprivileged user. That daemon is a long-running process that manages containers. Podman has no daemon; each command (like podman run) operates directly and exits. This affects:

  • Startup time: Podman commands start faster because there is no daemon to wake up.
  • Process model: Podman containers are direct children of the user’s shell; Docker containers are children of the daemon.
  • Systemd integration: Podman can generate systemd unit files (podman generate systemd) to manage containers as user services. Docker rootless also supports systemd, but it’s an extra layer.
  • Security: With Docker, the daemon is a privileged process (even in rootless mode, it has more capabilities than a regular user). Podman’s model gives each container a more isolated set of privileges.

Which One Should You Choose?

Your choice depends on your workflow and existing tooling.

  • Choose Podman if: you want a daemonless, systemd-friendly setup, or you are migrating from Docker and want to avoid a daemon. Podman can run Docker-compatible commands (via podman-docker package) and supports Docker Compose with podman-compose or podman compose.
  • Choose Docker if: you rely on Docker Swarm, or you need the Docker API for third-party tools (like Portainer). Docker rootless still provides the full Docker API, which many tools expect.

Both work well for development and production. In practice, Podman is often preferred on Fedora/RHEL systems because it is integrated into the OS, while Docker is more common on Ubuntu and in CI pipelines.

Common Problems and Misconceptions

One common misconception is that rootless containers are slower. In practice, the performance difference is negligible for most workloads. The main overhead comes from user-mode networking (slirp4netns) which can be slower for high-throughput network traffic. Docker and Podman both use it, but Podman offers pasta as a faster alternative.

Another issue is port binding. In rootless mode, you cannot bind to ports below 1024 (like port 80) directly, because unprivileged users cannot bind to privileged ports. Workarounds include using a reverse proxy (like Caddy or nginx) that runs as root, or using sysctl net.ipv4.ip_unprivileged_port_start=0 (not recommended for security).

Also, rootless containers cannot mount most filesystems (like NFS) unless the user has the necessary capabilities. This is a limitation of user namespaces, not specific to Docker or Podman.

Security Considerations

Rootless mode reduces the risk of container escape because the container processes run with the privileges of an unprivileged user. However, it is not a silver bullet. There have been vulnerabilities in user namespace handling, so keep your kernel and container runtime updated.

Both Docker and Podman in rootless mode use user namespaces to map the container root to an unprivileged host user. This means that even if an attacker breaks out of the container, they only get the privileges of that user, not root. However, the user can still access files owned by that user, so it’s important to run containers with a dedicated user account that has limited access.

Frequently Asked Questions

Can I run Docker Compose with Podman rootless?

Yes, you can use podman-compose or the built-in podman compose command (which uses the Docker Compose specification). You may need to adjust the compose file for rootless networking (e.g., using network_mode: slirp4netns).

Do rootless containers work with Kubernetes?

Kubernetes itself runs containers as root by default, but you can use rootless containers with Kubernetes by running kubelet in rootless mode (experimental) or using Podman’s Kubernetes integration (podman play kube) which works rootless.

Is rootless mode slower than rootful mode?

For most workloads, the performance difference is minimal. The main overhead is in networking (slirp4netns) and storage (fuse-overlayfs). Using pasta for networking and native overlayfs (if available) can reduce the gap.

Can I use GPU with rootless containers?

Yes, both Docker and Podman support GPU passthrough in rootless mode, but it requires additional setup. For Docker, you need the NVIDIA Container Toolkit configured for rootless. For Podman, you can use the --device flag to pass the GPU device.

Why does my rootless container fail to bind to port 80?

Unprivileged users cannot bind to ports below 1024. Use a port above 1024 and redirect with a reverse proxy, or set the sysctl net.ipv4.ip_unprivileged_port_start=80 (not recommended).

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →