1buildah-unshare(1) General Commands Manual buildah-unshare(1)
2
3
4
6 buildah-unshare - Run a command inside of a modified user namespace.
7
8
10 buildah unshare [options] [--] [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 buildah 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 buildah mount command. If an
28 unprivileged users wants to mount and work with a container, then they
29 need to execute buildah unshare. Executing buildah mount fails for
30 unprivileged users unless the user is running inside a buildah unshare
31 session.
32
33
35 --mount [VARIABLE=]containerNameOrID
36
37
38 Mount the containerNameOrID container while running command, and set
39 the environment variable VARIABLE to the path of the mountpoint. If
40 VARIABLE is not specified, it defaults to containerNameOrID, which may
41 not be a valid name for an environment variable.
42
43
45 buildah unshare id
46
47
48 buildah unshare pwd
49
50
51 buildah unshare cat /proc/self/uid_map /proc/self/gid_map
52
53
54 buildah unshare rm -fr $HOME/.local/share/containers/storage
55 /run/user/`id -u`/run
56
57
58 buildah unshare --mount containerID sh -c 'cat ${con‐
59 tainerID}/etc/os-release'
60
61
62 If you want to use buildah with a mount command then you can create a
63 script that looks something like:
64
65
66 cat buildah-script.sh << _EOF
67 #!/bin/sh
68 ctr=$(buildah from scratch)
69 mnt=$(buildah mount $ctr)
70 dnf -y install --installroot=$mnt PACKAGES
71 dnf -y clean all --installroot=$mnt
72 buildah config --entrypoint="/bin/PACKAGE" --env "FOO=BAR" $ctr
73 buildah commit $ctr imagename
74 buildah unmount $ctr
75 _EOF
76
77
78
79 Then execute it with:
80
81
82 buildah unshare buildah-script.sh
83
84
85
87 buildah(1), buildah-mount(1), namespaces(7), newuidmap(1),
88 newgidmap(1), user_namespaces(7)
89
90
91
92buildah June 2018 buildah-unshare(1)