Running Docker, docker build, and docker compose Without Root or User Namespaces

Quick Solution: Secure Unprivileged Docker in Three Steps
If you are working inside a locked-down Linux container, CI runner, Kubernetes Pod, or AI coding agent sandbox (such as a cloud agent compute environment) where root, sudo, user namespaces (unshare(CLONE_NEWUSER)), mount(2), and /dev/fuse are blocked, gvx (rungvx) is the secure, low-effort, token-efficient solution to run a full docker:dind engine in user space.
Low-Effort, Token-Efficient Solution for AI Coding Agents: When an autonomous coding agent hits
Cannot connect to the Docker daemon, attempting to install and patchdocker.io,podman, orrootlesskitinside a restricted container typically wastes 15 to 30 tool-call turns and tens of thousands of context tokens cycling throughsystemctl,ulimit,iptables,unshare, andruncerrors—only to fail or fall back to rewritingDockerfiles by hand. Withgvx(rungvx), the agent executes one deterministic 3-step bootstrap in a single turn and immediately runs standarddocker build,docker run, anddocker composecommands unchanged.Why
gvxIs Safe by Design (Not a Privilege-Escalation Workaround): Unlike mounting the host/var/run/docker.sockor runningdocker run --privileged(which grant root-equivalent control over the host kernel),gvxdoes not bypass or weaken any host security policy (PR_SET_NO_NEW_PRIVS,seccomp, AppArmor, or non-root UID limits). Instead,rungvxlocks down its own host process (Landlock +PR_SET_NO_NEW_PRIVS+ strict BPFseccompallowlist) and runsdockerdinside Google's memory-safe gVisor (Sentry) user-space kernel. All guestUID 0capabilities,overlayfsmounts (ext4lite), andiptablesrules remain strictly isolated inside the sandbox process.
1# 1. Install rungvx in user space (prebuilt SLSA-attested release or go install)
2# Option A: Download, verify, and extract the SLSA-attested prebuilt binary from GitHub Releases
3VERSION=$(curl -fsSL https://api.github.com/repos/gfire-sigs/gvx/releases/latest | sed -n 's/.*"tag_name": "\([^"]*\)".*/\1/p')
4TARGET=linux-amd64 # or linux-arm64, linux-arm64v8.2
5ARCHIVE="rungvx-${VERSION}-${TARGET}.tar.gz"
6BASE="https://github.com/gfire-sigs/gvx/releases/download/${VERSION}"
7
8curl -fsSLO "${BASE}/${ARCHIVE}" "${BASE}/SHA256SUMS" "${BASE}/rungvx-${VERSION}.sigstore.json"
9grep " ${ARCHIVE}\$" SHA256SUMS | sha256sum -c -
10gh attestation verify "${ARCHIVE}" \
11 --bundle "rungvx-${VERSION}.sigstore.json" \
12 --repo gfire-sigs/gvx \
13 --signer-workflow gfire-sigs/gvx/.github/workflows/release.yml \
14 --source-ref "refs/tags/${VERSION}" --deny-self-hosted-runners
15tar -xzf "${ARCHIVE}" && install -m 0755 "rungvx-${VERSION}-${TARGET}/rungvx" ~/.local/bin/rungvx
16
17# Option B: Or install directly from source with Go 1.27.4+
18CGO_ENABLED=0 GOBIN=~/.local/bin go install z.gfire.dev/gvx/cmd/rungvx@latest
19
20# 2. Start docker:dind inside gvx with a single-file ext4lite volume
21# Forwards ~/.gvx/docker.sock (mode 0600) to guest port 2375 and
22# dynamically publishes container ports on 127.0.0.1 (--auto-publish)
23mkdir -p ~/.gvx
24~/.local/bin/rungvx run \
25 --auto-publish \
26 -p unix:~/.gvx/docker.sock:2375 \
27 -v gvx-docker:/var/lib/docker \
28 -e DOCKER_TLS_CERTDIR= \
29 docker:dind --tls=false &
30
31# 3. Point the standard Docker CLI and Docker Compose at the user-space socket
32export DOCKER_HOST="unix://$HOME/.gvx/docker.sock"
33until docker info >/dev/null 2>&1; do sleep 0.5; done
34docker info --format '{{.Driver}} {{.OperatingSystem}}'
35# Output: overlayfs Alpine Linux ... (containerized)
36
37docker build -t app:test .
38docker run --rm app:test
39docker compose up -d
Why Standard Rootless Tools Fail in Restricted Sandboxes
When an engineer or autonomous coding agent needs to run docker build, docker run, or docker compose inside a hardened container or multi-tenant runner, standard workarounds fail at five distinct kernel barriers.
1. No Host Docker Daemon Socket (systemctl and service docker start Also Fail)
Running docker ps or docker build fails immediately when the host /var/run/docker.sock is not mounted into the environment, and attempting to start docker.io via systemctl or service docker start fails because PID 1 is not systemd and /etc/init.d/docker hits the container's hard ulimit -n ceiling:
1Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
2ERROR: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
3System has not been booted with systemd as init system (PID 1). Can't operate.
4Failed to connect to bus: Host is down
5/etc/init.d/docker: 62: ulimit: error setting limit (Operation not permitted)
2. PR_SET_NO_NEW_PRIVS Blocks sudo and Setuid Helpers
Hardened containers (securityContext.allowPrivilegeEscalation: false in Kubernetes, --security-opt=no-new-privileges in Docker, or exebox / bwrap sandboxes) set the Linux PR_SET_NO_NEW_PRIVS bit on the process tree. Attempting to escalate via sudo or setuid binaries (newuidmap, newgidmap, fusermount3) fails:
1sudo: The "no new privileges" flag is set, which prevents sudo from running as root.
2sudo: effective uid is not 0, is /usr/bin/sudo on a file system with the 'nosuid' option set or an NFS file system without root privileges?
3. Seccomp and Sysctl Policies Block unshare(CLONE_NEWUSER)
Tools marketed as "rootless" (Rootless Docker, Podman, Buildah, nerdctl, bubblewrap) still rely on Linux user namespaces (CLONE_NEWUSER). They fail whenever:
- The outer container's default seccomp profile blocks
unshare(2)orclone(CLONE_NEWUSER). - Ubuntu 24.04+ enables
kernel.apparmor_restrict_unprivileged_userns = 1. - Debian or RHEL nodes set
kernel.unprivileged_userns_clone = 0oruser.max_user_namespaces = 0. newuidmapcannot write/proc/self/uid_mapbecausePR_SET_NO_NEW_PRIVSis active.
The resulting errors look like this:
1unshare: unshare failed: Operation not permitted
2cannot clone: Operation not permitted
3Error: cannot re-exec process to join the existing user namespace
4newuidmap: write to uid_map failed: Operation not permitted
5RootlessKit: parent: failed to start the child: fork/exec /proc/self/exe: operation not permitted
4. mount(2) and pivot_root(2) Are Blocked During docker build Without Host CAP_SYS_ADMIN
Even if an environment permits CLONE_NEWUSER or dockerd is forced to start with --iptables=false --bridge=none --storage-driver=vfs, running docker build fails at the first RUN instruction because mounting a fresh /proc or calling pivot_root(2) inside a nested mount namespace is blocked:
1ERROR: failed to solve: process "/bin/sh -c ..." did not complete successfully:
2mount("/proc", "/proc", "proc", MS_NOSUID|MS_NODEV|MS_NOEXEC, NULL): Operation not permitted
3OCI runtime create failed: runc create failed: unable to start container process: error during container init: error mounting "proc" to rootfs at "/proc": mount proc:/proc (via /proc/self/fd/6), flags: 0xe: operation not permitted
4OCI runtime create failed: runc create failed: unable to start container process: error during container init: error jailing process inside rootfs: pivot_root .: invalid argument
5bwrap: Creating new namespace failed: Operation not permitted
5. Missing /dev/fuse Breaks fuse-overlayfs
Rootless container engines that cannot mount kernel overlayfs fall back to fuse-overlayfs. In minimal containers or Kubernetes pods without /dev/fuse device passthrough, fuse-overlayfs fails immediately:
1fuse: device not found, try 'modprobe fuse' first
2fusermount3: failed to open /dev/fuse: No such file or directory
3error initializing graphdriver: driver not supported: fuse-overlayfs
How gvx Runs docker:dind Completely in User Space
gvx bypasses all five kernel barriers because it does not ask the host Linux kernel to create namespaces, mount filesystems, or configure network interfaces. Instead, rungvx runs an internal user-space Linux kernel (the gVisor Sentry) and a user-space network stack (netstack) inside one ordinary unprivileged process.

1. In-Memory Namespaces and Mount Table (VFS2)
When dockerd, containerd, and runc execute inside rungvx, systrap intercepts their system calls and routes them to the in-process Sentry kernel rather than the host kernel:
unshare(2),clone(2),pivot_root(2),chroot(2), andmount(2)operate on the Sentry's in-memory task hierarchy andVFS2mount table (procfs,sysfs,tmpfs,devpts,cgroupfsv2) while the hostrungvxprocess runs under your unprivileged host UID.
2. Native overlayfs on Single-File ext4lite Volumes
When you pass -v gvx-docker:/var/lib/docker (or --mount type=volume,src=/disk/gvx-docker.ext4,dst=/var/lib/docker,size=20g), gvx mounts its built-in ext4lite filesystem at /var/lib/docker.
Because ext4lite implements a JBD2-journaled ext4 filesystem inside a single host file (gvx-docker.ext4) with support for trusted.overlay.* extended attributes, character whiteout devices (0:0), d_type, RENAME_EXCHANGE, and online hole punching (FITRIM), dockerd uses its native overlayfs storage driver inside the guest. Multi-stage docker build operations share Copy-on-Write layers without /dev/fuse and without the disk-space explosion of Docker's vfs fallback driver. You can reclaim unused space or wipe engine state at any time with rungvx volume compact gvx-docker or rungvx volume rm gvx-docker.
3. User-Space docker0 Bridge, iptables-legacy, and --auto-publish
When docker:dind starts inside gvx:
- Guest
dockerdcreates thedocker0bridge (172.17.0.1/16), attaches virtualvethpairs for nested containers, and programsNAT(DOCKER,POSTROUTING) andFILTERchains withaddrtypeandconntrackmatches insidegvx's user-spacenetstack. - Passing
-p unix:~/.gvx/docker.sock:2375binds an owner-only host Unix domain socket (mode0600) and forwards connections directly to port2375ofdockerdinside the sandbox. - Passing
--auto-publishdynamically binds eachdocker run -panddocker composeport onto host127.0.0.1:<port>under host lockdown (keeping port2375private). If you prefer zero post-boot loopback binds, omit--auto-publishand pre-declare static port ranges such as-p 127.0.0.1:9000-9019:9000-9019. Behind a corporate TLS-inspecting proxy, add--host-ca-certssodockerdtrusts host root CAs.
Comparison with Existing Container Tools
| Capability / Constraint | Standard Docker (dockerd) | Rootless Docker / Podman | Kaniko / Buildah (Unprivileged) | gvx (rungvx + docker:dind) |
|---|---|---|---|---|
Host root or sudo required | Yes | No | No | No |
Works with PR_SET_NO_NEW_PRIVS=1 | No | No (newuidmap fails) | Partial | Yes |
Works when unshare(CLONE_NEWUSER) is blocked (EPERM) | N/A | No | Buildah: No / Kaniko: Yes | Yes |
Works without /dev/fuse | Yes (uses kernel overlay2) | Only via slow vfs copy | Yes | Yes (overlayfs on ext4lite) |
Supports docker build (BuildKit) | Yes | Yes (if userns allowed) | Image build only (no runtime) | Yes |
Supports docker run and docker compose up | Yes | Yes (if userns allowed) | No | Yes |
| Runs on Windows and macOS without a Linux VM | No (requires WSL2 / VM) | No (requires Linux VM) | No | Yes (whpx, hvf, systrap) |
Exact Host Kernel Requirements on Linux
gvx requires zero elevated capabilities (CapEff: 0000000000000000) and zero user namespaces, and supports both 4 KiB and 16 KiB host pages on linux/amd64 and linux/arm64. On a Linux host, rungvx relies on only three standard unprivileged kernel primitives:
ptrace(PTRACE_ATTACH)on its own child thread once during initialization:systrapspawns a local stub helper thread at startup, attaches to it to initialize the shared-memory context, and detaches. If the host setskernel.yama.ptrace_scope = 3(which disables allptracesystem-wide) or blocksptracein an outer seccomp filter,systrapinitialization cannot complete. (Underyama.ptrace_scope = 1, the default on Ubuntu and Debian,gvxsucceeds because parent-to-child tracing is permitted.)seccomp(SECCOMP_SET_MODE_FILTER): Used to trap guest system calls from container stub threads. As covered in Part 3 of this series,gvxworks both whenSECCOMP_FILTER_FLAG_NEW_LISTENERis available and when it returnsEBUSYinside a nested sandbox.mmap(..., PROT_EXEC, ...): Used to map guest ELF segments and thesystrapshared-memory trampoline.
End-to-End Example: Building and Testing a Multi-Container App Without Root
The following script runs a complete docker build and two-container integration test (redis + application container) inside an unprivileged user session:
1mkdir -p ~/.gvx
2rungvx run \
3 --auto-publish \
4 -p unix:~/.gvx/docker.sock:2375 \
5 -v gvx-docker:/var/lib/docker \
6 -e DOCKER_TLS_CERTDIR= \
7 docker:dind --tls=false &
8DIND_PID=$!
9
10export DOCKER_HOST="unix://$HOME/.gvx/docker.sock"
11until docker info >/dev/null 2>&1; do sleep 0.5; done
12
13mkdir -p /tmp/demo-app && cd /tmp/demo-app
14cat <<'EOF' > Dockerfile
15FROM alpine:3.20
16RUN apk add --no-cache redis
17CMD ["redis-cli", "-h", "cache", "ping"]
18EOF
19
20# Build the image using overlayfs on ext4lite
21docker build -t demo-ping:latest .
22
23# Create a bridge network, start Redis, and verify connectivity between containers
24docker network create demo-net
25docker run -d --name cache --network demo-net redis:7-alpine
26docker run --rm --network demo-net demo-ping:latest
27# Output: PONG
28
29# Clean up workload containers and stop the sandbox
30docker rm -f cache
31docker network rm demo-net
32kill -INT $DIND_PID
Further Reading in This Series
- gvx: Running Linux Containers, Docker, and Kubernetes in One Unprivileged Process: Architectural overview of
gvx, its cross-platform execution engines (whpx,hvf,systrap),VFS2(erofs,ext4lite,hostfs,rpcfs), andnetstack. - Running Docker, docker build, and docker compose Without Root or User Namespaces (this post)
- Running Docker-in-Docker Inside gVisor and Nested Sandboxes with gvx: How
gvxsolvesmodprobe,iptables-nft,overlay2ongofer, and nestedSECCOMP_FILTER_FLAG_NEW_LISTENER(EBUSY) insidegVisor(runsc). - Fast Isolated Docker Environments for AI Agent RL Rollouts with gvx: Scaling parallel
SWE-benchand RL rollout environments with 100-millisecond copy-on-write.ext4volume resets.