Ditching the Daemon: Engineering Rootless Podman and Docker Compose Without Privileged Root
The standard Docker architecture runs a persistent root-owned daemon on the host system. While functional, running a high-privilege daemon multiplexing container workloads introduces a massive security surface...
The standard Docker architecture runs a persistent root-owned daemon (dockerd) on the host system. While functional, running a high-privilege daemon multiplexing container workloads introduces a massive security surface. A single container escape vulnerability yields root privileges on the host kernel. Rootless Podman eliminates the daemon entirely, relying on user namespaces and unprivileged user mappings. However, connecting declarative orchestration tools like Docker Compose to a daemonless, unprivileged container engine requires understanding socket activation, user session runtimes, and subtle API translation layers.
The Daemonless Architectural Shift: User Namespaces and Socket Activation
Traditional Docker architecture couples container lifecycle management to the dockerd daemon running as root. Podman adopts a fork-exec daemonless model: each container command runs as an independent process tree managed by conmon and an OCI runtime such as crun or runc. In rootless mode, the host maps unprivileged UIDs and GIDs via /etc/subuid and /etc/subgid, mapping container root to the executing user account.
Because Docker Compose expects a persistent REST API daemon to receive JSON payloads over a UNIX socket, direct daemonless execution fails without an intermediary translation service. Podman solves this via socket activation through systemd user units. When Docker Compose connects to the socket path, systemd spins up the API translation service on demand, avoiding idle resource consumption while maintaining API parity.
[Unit]
Description=Podman API Socket
Documentation=man:podman-system-service(1)
[Socket]
ListenStream=%t/podman/podman.sock
SocketMode=0660
[Install]
WantedBy=sockets.target
This systemd user unit listens on $XDG_RUNTIME_DIR/podman/podman.sock. When a client connects, systemd activates podman.service, binding the client stream directly to the Podman service without routing through a persistent daemon process.
Configuring the Rootless Socket and Environment Routing
To establish communication between Docker Compose and the rootless Podman engine, the user session runtime must activate the socket unit and export the appropriate socket path in the environment.
# Enable and start the user-level Podman socket
systemctl --user enable --now podman.socket
# Verify the socket is active and listening
systemctl --user status podman.socket
# Export the DOCKER_HOST environment variable
export DOCKER_HOST="unix://${XDG_RUNTIME_DIR}/podman/podman.sock"
# Test API connectivity using curl
curl --unix-socket "${XDG_RUNTIME_DIR}/podman/podman.sock" http://localhost/v4.0.0/libpod/info | jq '{Version, ApiVersion}'
By exporting DOCKER_HOST, any utility designed for the Docker ecosystem—including Docker Compose, Testcontainers, and IDE dev container extensions—routes its REST API requests directly to Podman's libpod API translator.
Bridging Docker Compose to Podman Libpod API
Docker Compose communicates with the container runtime by issuing HTTP requests over a UNIX socket. Podman implements a dual API stack: a Docker-compatible endpoint set (e.g., /v1.40/containers/json) and a native Libpod endpoint set (/v4.0.0/libpod/...). While simple container lifecycles (up, down, ps) map cleanly, complex Compose features encounter divergence.
Consider a standard multi-service Compose configuration running an Nginx frontend and a Redis cache:
version: '3.8'
services:
web:
image: docker.io/library/nginx:alpine
ports:
- "8080:80"
restart: unless-stopped
redis:
image: docker.io/library/redis:7-alpine
restart: unless-stopped
When running docker compose up -d against the Podman socket, Podman translates the Compose specification into individual OCI container configurations. However, several configuration keys behave differently in unprivileged rootless environments.
Network Stack Mechanics: Slirp4netns versus Pasta in Rootless Deployments
Rootless container networking introduces kernel isolation barriers that prevent containers from attaching directly to host network interfaces without privileged intervention. Podman historically relied on slirp4netns, a user-space networking implementation that translates TCP/UDP packets into user-space socket connections. While reliable, slirp4netns incurs significant packet serialization overhead, capping multi-gigabit throughput and introducing latency spikes under heavy TCP loads.
Modern Podman distributions adopt pasta (Packets A STream-based Abstraction), which performs transparent Layer 2 packet forwarding between host and container namespaces without routing through a TUN device bottleneck. Configuring network backends in containers.conf ensures Docker Compose workloads inherit optimal packet transmission rates.
[network]
network_backend = "pasta"
dns_bind_port = 53
When Compose provisions bridge networks for multi-container applications, pasta assigns each container a routable local IP address mapped directly through the user namespace boundary, enabling intra-service discovery without exposing ports to the external host network interface.
Storage Drivers and OverlayFS Limitations in Unprivileged Environments
Container image layering relies on union filesystems. Under rootful Docker, overlayfs operates natively at the kernel level across all layers. Rootless Podman faces a strict kernel constraint: prior to kernel 5.11 (and specific unprivileged overlay support patches in newer kernels or distributions like RHEL and Ubuntu), unprivileged users could not mount OverlayFS on top of another OverlayFS directory.
When unprivileged overlay mounting is unavailable, Podman falls back to the vfs storage driver. The vfs driver duplicates entire directory trees for every container layer rather than creating copy-on-write symlinks. This behavior multiplies disk consumption and drastically slows container build times and startup sequences.
{
"storage": {
"driver": "overlay",
"graphroot": "/home/diama/.local/share/containers/storage",
"runroot": "/run/user/1000/containers"
}
}
Verifying that the active storage driver is set to overlay in storage.conf is critical before provisioning heavy production stacks via Docker Compose. If fallback to vfs occurs, disk exhaustion during multi-stage image builds becomes inevitable.
Production Trade-Offs: Privileged Ports, SELinux, and Volume Ownership
Adopting rootless Podman with Docker Compose eliminates host root escalation vectors, but introduces operational constraints that require explicit handling in CI/CD pipelines and deployment manifests.
First, binding to privileged ports below 1024 (such as 80:80 or 443:443) fails under unprivileged execution unless kernel sysctls are modified (net.ipv4.ip_unprivileged_port_start=80). Production workflows should map high ports (e.g., 8080:80) behind an unprivileged reverse proxy like HAProxy or Nginx.
Second, volume mount permissions frequently cause initialization errors. Because rootless users map UID ranges, files created inside volumes by container processes may be owned by mapped sub-UIDs. Adding the :Z SELinux suffix or utilizing user namespace remapping flags ensures correct host-container ownership synchronization.
services:
database:
image: postgres:15-alpine
volumes:
- pgdata:/var/lib/postgresql/data:Z
volumes:
pgdata:
Third, persistent user services require lingering to survive user logouts. Failing to enable lingering causes background containers to terminate when the SSH session disconnects:
# Ensure user session survives logout for background services
sudo loginctl enable-linger $(whoami)
Benchmarking Operational Resilience and Failure Modes
Transitioning orchestration from dockerd to daemonless Podman shifts failure domains. In a traditional Docker deployment, a daemon crash orphans all running containers or requires a daemon restart flag (--live-restore). Podman's daemonless design ensures that container processes run independently under conmon; crashing the API service does not impact running container runtimes.
However, resource limits and systemd integration require rigorous tuning. When systemd manages user services, OOM (Out Of Memory) scores and cgroup v2 delegations dictate whether unprivileged containers can consume host swap and memory limits correctly. Verifying cgroup v2 availability is mandatory before deploying high-throughput stateful workloads in production.
# Verify systemd cgroup v2 delegation for rootless containers
podman info | grep -i "cgroupversion"
If cgroup version is 1, memory controllers cannot be delegated to unprivileged user sessions, leading to silent failures when applying strict memory limits in compose files. Upgrading host kernels to modern Linux distributions with default cgroup v2 controllers resolves these constraints entirely.
Image Building Pipelines: Integrating Buildah and Containerfile Spec
Beyond running pre-built container images, modern software delivery pipelines require building images directly from source repositories. Traditional Docker builds invoke the daemon to execute instructions. Podman delegates image building directly to Buildah, operating without a central daemon process.
When compiling multi-stage applications via Docker Compose (using the build: . directive), Podman translates the build context into unprivileged user namespace layers. Each instruction executes inside an isolated mount namespace, ensuring that build artifacts remain secured within the user's home directory storage path.
FROM golang:1.22-alpine AS builder
WORKDIR /app
COPY . .
RUN go build -o bin/server ./cmd/main.go
FROM alpine:3.20
COPY --from=builder /app/bin/server /usr/local/bin/server
EXPOSE 8080
CMD ["server"]
By enforcing rootless build isolation, compromised build steps cannot overwrite host system files or manipulate kernel parameters. The resulting image adheres strictly to OCI specifications, fully compatible with downstream registries and Kubernetes clusters.