1podman-unshare(1)() podman-unshare(1)()
2
3
4
6 podman-unshare - Run a command inside of a modified user namespace
7
8
10 podman unshare [--] [command]
11
12
14 Launches a process (by default, $SHELL) in a new user namespace. The
15 user namespace is configured so that the invoking user's UID and pri‐
16 mary GID appear to be UID 0 and GID 0, respectively. Any ranges which
17 match that user and group in /etc/subuid and /etc/subgid are also
18 mapped in as themselves with the help of the newuidmap(1) and
19 newgidmap(1) helpers.
20
21
22 podman unshare is useful for troubleshooting unprivileged operations
23 and for manually clearing storage and other data related to images and
24 containers.
25
26
27 It is also useful if you want to use the podman mount command. If an
28 unprivileged user wants to mount and work with a container, then they
29 need to execute podman unshare. Executing podman mount fails for un‐
30 privileged users unless the user is running inside a podman unshare
31 session.
32
33
34 The unshare session defines two environment variables:
35
36
37 • CONTAINERS_GRAPHROOT: the path to the persistent container's
38 data.
39
40 • CONTAINERS_RUNROOT: the path to the volatile container's data.
41
42
43
45 --help, -h
46 Print usage statement
47
48
49 --rootless-cni
50 Join the rootless network namespace used for CNI networking. It can be
51 used to connect to a rootless container via IP address (CNI network‐
52 ing). This is otherwise not possible from the host network namespace.
53 Note: Using this option with more than one unshare session can have un‐
54 expected results.
55
56
58 The exit code from podman unshare gives information about why the con‐
59 tainer failed to run or why it exited. When podman unshare commands
60 exit with a non-zero code, the exit codes follow the chroot standard,
61 see below:
62
63
64 125 The error is with podman itself
65
66
67 $ podman unshare --foo; echo $?
68 Error: unknown flag: --foo
69 125
70
71
72
73 126 Executing a contained command and the command cannot be invoked
74
75
76 $ podman unshare /etc; echo $?
77 Error: fork/exec /etc: permission denied
78 126
79
80
81
82 127 Executing a contained command and the command cannot be found
83
84
85 $ podman run busybox foo; echo $?
86 Error: fork/exec /usr/bin/bogus: no such file or directory
87 127
88
89
90
91 Exit code contained command exit code
92
93
94 $ podman run busybox /bin/sh -c 'exit 3'; echo $?
95 3
96
97
98
100 $ podman unshare id
101 uid=0(root) gid=0(root) groups=0(root),65534(nobody)
102
103 $ podman unshare cat /proc/self/uid_map /proc/self/gid_map
104 0 1000 1
105 1 10000 65536
106 0 1000 1
107 1 10000 65536
108
109 $ podman unshare --rootless-cni ip addr
110 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
111 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
112 inet 127.0.0.1/8 scope host lo
113 valid_lft forever preferred_lft forever
114 inet6 ::1/128 scope host
115 valid_lft forever preferred_lft forever
116 2: tap0: <BROADCAST,UP,LOWER_UP> mtu 65520 qdisc fq_codel state UNKNOWN group default qlen 1000
117 link/ether 36:0e:4a:c7:45:7e brd ff:ff:ff:ff:ff:ff
118 inet 10.0.2.100/24 brd 10.0.2.255 scope global tap0
119 valid_lft forever preferred_lft forever
120 inet6 fe80::340e:4aff:fec7:457e/64 scope link
121 valid_lft forever preferred_lft forever
122 3: cni-podman2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
123 link/ether 5e:3a:71:d2:b4:3a brd ff:ff:ff:ff:ff:ff
124 inet 10.89.1.1/24 brd 10.89.1.255 scope global cni-podman2
125 valid_lft forever preferred_lft forever
126 inet6 fe80::5c3a:71ff:fed2:b43a/64 scope link
127 valid_lft forever preferred_lft forever
128 4: vethd4ba3a2f@if3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master cni-podman2 state UP group default
129 link/ether 8a:c9:56:32:17:0c brd ff:ff:ff:ff:ff:ff link-netnsid 0
130 inet6 fe80::88c9:56ff:fe32:170c/64 scope link
131 valid_lft forever preferred_lft forever
132
133
134
136 podman(1), podman-mount(1), namespaces(7), newuidmap(1), newgidmap(1),
137 user_namespaces(7)
138
139
140
141 podman-unshare(1)()