podman-unshare(1)
π
podman-unshare β from the podman fam, General Commands Manual vibes
okay bestie, pull up a chair because this one is genuinely iconic. podman-unshare runs a command inside a modified user namespace. yeah. we're doing namespace surgery and it slays.
β¨ NAME β¨
podman-unshare β run a command inside of a modified user namespace π¦
πΈ SYNOPSIS πΈ
podman unshare [options] [command]
π DESCRIPTION π
so the tea is: this launches a process β by default, $SHELL β inside a new user namespace. and the namespace is configured so that your invoking user's UID and primary GID show up as UID 0 and GID 0 respectively. you're literally root in there. main character energy fr.
and any ranges that match that user and group in /etc/subuid and /etc/subgid also get mapped in as themselves, with a little help from the newuidmap(1) and newgidmap(1) helpers. teamwork makes the dream work π«Ά
podman unshare is useful for troubleshooting unprivileged operations and for manually clearing storage and other data related to images and containers.
it's ALSO useful when you wanna use the podman mount command. like, if an unprivileged user wants to mount and work with a container, they need to execute podman unshare first. executing podman mount just fails for unprivileged users unless the user is already running inside a podman unshare session. no unshare, no mount, that's the rule π
the unshare session defines two environment variables, and they're both lowkey important:
CONTAINERS_GRAPHROOT: the path to the persistent container's data.CONTAINERS_RUNROOT: the path to the volatile container's data.
β οΈ IMPORTANT: This command is not available with the remote Podman client. periodt.
π OPTIONS π
--help, -h
Print usage statement. cute and simple, it just tells you how to use it β¨
--rootless-netns
Join the rootless network namespace used for netavark networking. it can be used to connect to a rootless container via IP address (bridge networking). this is otherwise not possible from the host network namespace. so basically: normally impossible, but with this flag? possible π
π¦ Exit Codes π¦
the exit code from podman unshare gives you information about why the container failed to run or why it exited. when podman unshare commands exit with a non-zero code, the exit codes follow the chroot standard, see below:
125 β The error is with podman itself
$ podman unshare --foo; echo $?
Error: unknown flag: --foo
125
126 β Executing a contained command and the command cannot be invoked
$ podman unshare /etc; echo $?
Error: fork/exec /etc: permission denied
126
127 β Executing a contained command and the command cannot be found
$ podman unshare foo; echo $?
Error: fork/exec /usr/bin/bogus: no such file or directory
127
Exit code contained command exit code β whatever the command you ran decided to exit with, you get that back
$ podman unshare /bin/sh -c 'exit 3'; echo $?
3
π₯ EXAMPLE π₯
Execute specified command in rootless user namespace:
$ podman unshare id
uid=0(root) gid=0(root) groups=0(root),65534(nobody)
Show user namespace mappings for rootless containers:
$ podman unshare cat /proc/self/uid_map /proc/self/gid_map
0 1000 1
1 10000 65536
0 1000 1
1 10000 65536
Show rootless netns information in user namespace for rootless containers:
$ podman unshare --rootless-netns ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: tap0: <BROADCAST,UP,LOWER_UP> mtu 65520 qdisc fq_codel state UNKNOWN group default qlen 1000
link/ether aa:8c:0b:73:98:f6 brd ff:ff:ff:ff:ff:ff
inet 10.0.2.100/24 brd 10.0.2.255 scope global tap0
valid_lft forever preferred_lft forever
inet6 fd00::a88c:bff:fe73:98f6/64 scope global dynamic mngtmpaddr
valid_lft 86389sec preferred_lft 14389sec
inet6 fe80::a88c:bff:fe73:98f6/64 scope link
valid_lft forever preferred_lft forever
π§ SEE ALSO π§
podman(1), podman-mount(1), namespaces(7), newuidmap(1), newgidmap(1), user_namespaces(7)
and that's the whole page, bestie β the podman-unshare(1) manual page itself, coming to you straight from the General Commands Manual. now go forth and unshare responsibly ππβ¨
π¦ where this page comes from
- arch rolling: podman-docker 6.1.4-1 Β· Apache-2.0
- fedora 43: podman-docker 5:5.6.2-1.fc43 Β· Apache-2.0 AND BSD-2-Clause AND BSD-3-Clause AND ISC AND MIT AND MPL-2.0
- fedora 43: podman-docker 5:5.8.4-1.fc43
- fedora 43: podman-docker 5:5.8.8-1.fc43
- fedora 43: podman-docker 5:5.8.9-1.fc43 Β· Apache-2.0 AND BSD-2-Clause AND BSD-3-Clause AND ISC AND MIT AND MPL-2.0
- fedora 44: podman-docker 5:5.8.1-1.fc44 Β· Apache-2.0 AND BSD-2-Clause AND BSD-3-Clause AND ISC AND MIT AND MPL-2.0
- fedora 44: podman-docker 5:5.8.7-1.fc44
- fedora 44: podman-docker 5:5.8.9-1.fc44 Β· Apache-2.0 AND BSD-2-Clause AND BSD-3-Clause AND ISC AND MIT AND MPL-2.0
- ubuntu resolute: podman-docker 5.7.0+ds2-3build1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms