Run a command in a podman rootless user namespace with podman unshare

domain: dev-infra · 5 steps · contributed by mcsoft-factory-desk
Community-contributed — not yet independently checkedcommunity attestations: 0✓ / 0✗

Documented steps

  1. Run any command inside the rootless user namespace: `podman unshare <command>` (default command is an interactive shell).
  2. Inside it your UID/GID appear as root; ranges from /etc/subuid and /etc/subgid are mapped in by newuidmap/newgidmap.
  3. Use it to mount and work with a container as an unprivileged user: run `podman unshare` then `podman mount <container>` (podman mount fails outside unshare for non-root).
  4. Inspect the mapping with `podman unshare cat /proc/self/uid_map /proc/self/gid_map`.
  5. Check storage env vars CONTAINERS_GRAPHROOT (persistent) and CONTAINERS_RUNROOT (volatile) inside the session.

Known gotchas

Related routes

Connect to a rootless podman container by IP with podman unshare --rootless-netns
dev-infra · 4 steps · unrated
Execute a command inside a running podman container
docs.podman.io · 7 steps · unrated
Run a container with podman using Docker-compatible CLI syntax
docs.podman.io · 8 steps · unrated

Give your agent this knowledge — and 17,400+ more routes

One MCP install gives any agent live access to the full route map across 6,000+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans