1buildah-run(1)              General Commands Manual             buildah-run(1)
2
3
4

NAME

6       buildah-run - Run a command inside of the container.
7
8

SYNOPSIS

10       buildah run [options] [--] container command
11
12

DESCRIPTION

14       Launches  a  container and runs the specified command in that container
15       using the container's root filesystem as a root filesystem, using  con‐
16       figuration  settings  inherited from the container's image or as speci‐
17       fied using previous calls to the buildah config  command.   To  execute
18       buildah run within an interactive shell, specify the --tty option.
19
20

OPTIONS

22       --add-history
23
24
25       Add  an  entry to the history which will note what command is being in‐
26       voked.  Defaults to false.
27
28
29       Note: You can also override the default value of --add-history by  set‐
30       ting  the  BUILDAH_HISTORY  environment  variable.  export BUILDAH_HIS‐
31       TORY=true
32
33
34       --cap-add=CAP_xxx
35
36
37       Add the specified capability to the set of capabilities which  will  be
38       granted  to the specified command.  Certain capabilities are granted by
39       default; this option can be used to add more beyond the defaults, which
40       may  have  been  modified by --cap-add and --cap-drop options used with
41       the buildah from invocation which created the container.
42
43
44       --cap-drop=CAP_xxx
45
46
47       Add the specified capability from the set of capabilities which will be
48       granted  to  the  specified  command.   The CAP_AUDIT_WRITE, CAP_CHOWN,
49       CAP_DAC_OVERRIDE,   CAP_FOWNER,   CAP_FSETID,   CAP_KILL,    CAP_MKNOD,
50       CAP_NET_BIND_SERVICE, CAP_SETFCAP, CAP_SETGID, CAP_SETPCAP, CAP_SETUID,
51       and CAP_SYS_CHROOT capabilities are granted by default; this option can
52       be  used to remove them from the defaults, which may have been modified
53       by --cap-add and --cap-drop options used with the buildah from  invoca‐
54       tion which created the container.
55
56
57       If  a  capability is specified to both the --cap-add and --cap-drop op‐
58       tions, it will be dropped, regardless of the order in which the options
59       were given.
60
61
62       --cgroupns how
63
64
65       Sets  the  configuration  for  the cgroup namespaces for the container.
66       The configured value can be "" (the empty string) or "private" to indi‐
67       cate that a new cgroup namespace should be created, or it can be "host"
68       to indicate that the cgroup namespace in which buildah itself is  being
69       run should be reused.
70
71
72       --contextdir directory
73
74
75       Allows setting context directory for current RUN invocation. Specifying
76       a context directory causes RUN context to consider context directory as
77       root directory for specified source in --mount of type 'bind'.
78
79
80       --env, -e env=value
81
82
83       Temporarily  add  a  value  (e.g. env=value) to the environment for the
84       running process. Unlike buildah config --env, the environment will  not
85       persist  to  later  calls  to buildah run or to the built image. Can be
86       used multiple times.
87
88
89       --hostname
90
91
92       Set the hostname inside of the running container.
93
94
95       --ipc how
96
97
98       Sets the configuration for the IPC namespaces for the  container.   The
99       configured  value can be "" (the empty string) or "private" to indicate
100       that a new IPC namespace should be created, or it can be "host" to  in‐
101       dicate  that  the  IPC  namespace  in which buildah itself is being run
102       should be reused, or it can be the path to an IPC  namespace  which  is
103       already in use by another process.
104
105
106       --isolation type
107
108
109       Controls  what type of isolation is used for running the process.  Rec‐
110       ognized types include oci (OCI-compatible runtime, the default),  root‐
111       less  (OCI-compatible  runtime  invoked using a modified configuration,
112       with --no-new-keyring added  to  its  create  invocation,  reusing  the
113       host's  network  and  UTS  namespaces,  and  creating private IPC, PID,
114       mount, and user namespaces; the default for  unprivileged  users),  and
115       chroot  (an internal wrapper that leans more toward chroot(1) than con‐
116       tainer technology, reusing the host's control group, network, IPC,  and
117       PID namespaces, and creating private mount and UTS namespaces, and cre‐
118       ating user namespaces only when they're required for ID mapping).
119
120
121       Note: You can also override the default isolation type by  setting  the
122       BUILDAH_ISOLATION environment variable.  export BUILDAH_ISOLATION=oci
123
124
125       --mount=type=TYPE,TYPE-SPECIFIC-OPTION[,...]
126
127
128       Attach a filesystem mount to the container
129
130
131       Current  supported  mount  TYPES are bind, cache, secret and tmpfs. [1]
132       ⟨#Footnote1⟩
133
134
135                 e.g.
136
137                 type=bind,source=/path/on/host,destination=/path/in/container
138
139                 type=tmpfs,tmpfs-size=512M,destination=/path/in/container
140
141                 type=cache,target=/path/in/container
142
143                 Common Options:
144
145                        · src, source: mount source spec for bind and volume. Mandatory for bind. If `from` is specified, `src` is the subpath in the `from` field.
146
147                        · dst, destination, target: mount destination spec.
148
149                        · ro, read-only: true or false (default).
150
151                 Options specific to bind:
152
153                        · bind-propagation: shared, slave, private, rshared, rslave, or rprivate(default). See also mount(2).
154
155                        . bind-nonrecursive: do not setup a recursive bind mount.  By default it is recursive.
156
157                        · from: stage or image name for the root of the source. Defaults to the build context.
158
159                 Options specific to tmpfs:
160
161                        · tmpfs-size: Size of the tmpfs mount in bytes. Unlimited by default in Linux.
162
163                        · tmpfs-mode: File mode of the tmpfs in octal. (e.g. 700 or 0700.) Defaults to 1777 in Linux.
164
165                        · tmpcopyup: Path that is shadowed by the tmpfs mount is recursively copied up to the tmpfs itself.
166
167                 Options specific to secret:
168
169                        · id: the identifier for the secret passed into the `buildah bud --secret` or `podman build --secret` command.
170
171                 Options specific to cache:
172
173                        · id: Create a separate cache directory for a particular id.
174
175                        · mode: File mode for new cache directory in octal. Default 0755.
176
177                        · ro, readonly: read only cache if set.
178
179                        · uid: uid for cache directory.
180
181                        · gid: gid for cache directory.
182
183                        · from: stage name for the root of the source. Defaults to host cache directory.
184
185
186
187       --network, --net=mode
188
189
190       Sets the configuration for the network namespace for the container.
191
192
193none: no networking;
194
195host: use the host network stack. Note: the  host  mode  gives
196                the  container full access to local system services such as D-
197                bus and is therefore considered insecure;
198
199ns:path: path to a network namespace to join;
200
201private: create a new namespace for the container (default)
202
203
204
205       --no-hosts
206
207
208       Do not create /etc/hosts for the container.
209
210
211       By default, Buildah manages /etc/hosts, adding the container's  own  IP
212       address.   --no-hosts disables this, and the image's /etc/hosts will be
213       preserved unmodified.
214
215
216       --no-pivot
217
218
219       Do not use pivot root to jail process inside  rootfs.  This  should  be
220       used whenever the rootfs is on top of a ramdisk.
221
222
223       Note:  You  can  make  this  option  the  default  by setting the BUIL‐
224       DAH_NOPIVOT environment variable.  export BUILDAH_NOPIVOT=true
225
226
227       --pid how
228
229
230       Sets the configuration for the PID namespace for  the  container.   The
231       configured  value can be "" (the empty string) or "private" to indicate
232       that a new PID namespace should be created, or it can be "host" to  in‐
233       dicate  that  the  PID  namespace  in which buildah itself is being run
234       should be reused, or it can be the path to a PID namespace which is al‐
235       ready in use by another process.
236
237
238       --runtime path
239
240
241       The  path  to  an alternate OCI-compatible runtime. Default is runc, or
242       crun when machine is configured to use cgroups V2.
243
244
245       Note: You can also override the default runtime by  setting  the  BUIL‐
246       DAH_RUNTIME environment variable.  export BUILDAH_RUNTIME=/usr/bin/crun
247
248
249       --runtime-flag flag
250
251
252       Adds  global  flags  for  the  container runtime. To list the supported
253       flags, please consult the manpages of the selected  container  runtime.
254       Note:  Do  not  pass  the leading -- to the flag. To pass the runc flag
255       --log-format json to buildah run, the option given would be  --runtime-
256       flag log-format=json.
257
258
259       --tty, --terminal, -t
260
261
262       By default a pseudo-TTY is allocated only when buildah's standard input
263       is attached to a pseudo-TTY.  Setting the --tty  option  to  true  will
264       cause  a pseudo-TTY to be allocated inside the container connecting the
265       user's "terminal" with the stdin and stdout stream  of  the  container.
266       Setting  the --tty option to false will prevent the pseudo-TTY from be‐
267       ing allocated.
268
269
270       --user user[:group]
271
272
273       Set the user to be used for running the command in the container.   The
274       user  can  be specified as a user name or UID, optionally followed by a
275       group name or GID, separated by a colon (':').  If names are used,  the
276       container should include entries for those names in its /etc/passwd and
277       /etc/group files.
278
279
280       --uts how
281
282
283       Sets the configuration for the UTS namespace for  the  container.   The
284       configured  value can be "" (the empty string) or "private" to indicate
285       that a new UTS namespace should be created, or it can be "host" to  in‐
286       dicate  that  the  UTS  namespace  in which buildah itself is being run
287       should be reused, or it can be the path to a UTS namespace which is al‐
288       ready in use by another process.
289
290
291       --volume, -v source:destination:options
292
293
294       Create a bind mount. If you specify, -v /HOST-DIR:/CONTAINER-DIR, Buil‐
295       dah bind mounts /HOST-DIR in the host to /CONTAINER-DIR in the  Buildah
296       container.  The  OPTIONS  are  a  comma  delimited list and can be: [1]
297       ⟨#Footnote1⟩
298
299
300              • [rw|ro]
301
302              • [U]
303
304              • [z|Z]
305
306              • [[r]shared|[r]slave|[r]private]
307
308
309
310       The CONTAINER-DIR must be an absolute path such as /src/docs. The HOST-
311       DIR  must be an absolute path as well. Buildah bind-mounts the HOST-DIR
312       to the path you specify. For example, if you supply /foo  as  the  host
313       path,  Buildah  copies the contents of /foo to the container filesystem
314       on the host and bind mounts that into the container.
315
316
317       You can specify multiple  -v options to mount one or more mounts  to  a
318       container.
319
320
321       Write Protected Volume Mounts
322
323
324       You  can add the :ro or :rw suffix to a volume to mount it read-only or
325       read-write mode, respectively. By  default,  the  volumes  are  mounted
326       read-write.  See examples.
327
328
329       Chowning Volume Mounts
330
331
332       By  default, Buildah does not change the owner and group of source vol‐
333       ume directories mounted into containers. If a container is created in a
334       new  user namespace, the UID and GID in the container may correspond to
335       another UID and GID on the host.
336
337
338       The :U suffix tells Buildah to use the correct host UID and  GID  based
339       on  the UID and GID within the container, to change the owner and group
340       of the source volume.
341
342
343       Labeling Volume Mounts
344
345
346       Labeling systems like SELinux require that proper labels are placed  on
347       volume  content mounted into a container. Without a label, the security
348       system might prevent the processes running inside  the  container  from
349       using  the  content. By default, Buildah does not change the labels set
350       by the OS.
351
352
353       To change a label in the container context, you can add either  of  two
354       suffixes  :z  or :Z to the volume mount. These suffixes tell Buildah to
355       relabel file objects on the shared volumes. The z option tells  Buildah
356       that  two containers share the volume content. As a result, Buildah la‐
357       bels the content with a shared content label. Shared volume labels  al‐
358       low  all  containers to read/write content.  The Z option tells Buildah
359       to label the content with a private unshared label.  Only  the  current
360       container can use a private volume.
361
362
363       By default bind mounted volumes are private. That means any mounts done
364       inside container will not be visible on the host and vice  versa.  This
365       behavior  can be changed by specifying a volume mount propagation prop‐
366       erty.
367
368
369       When the mount propagation policy is set to  shared,  any  mounts  com‐
370       pleted  inside the container on that volume will be visible to both the
371       host and container. When the mount propagation policy is set to  slave,
372       one  way  mount  propagation is enabled and any mounts completed on the
373       host for that volume will be visible only inside of the container.   To
374       control   the   mount  propagation  property  of  the  volume  use  the
375       :[r]shared, :[r]slave or :[r]private propagation flag. The  propagation
376       property can be specified only for bind mounted volumes and not for in‐
377       ternal volumes or named volumes. For mount propagation to work  on  the
378       source  mount point (the mount point where source dir is mounted on) it
379       has to have the right propagation properties. For shared  volumes,  the
380       source  mount point has to be shared. And for slave volumes, the source
381       mount has to be either shared or slave. [1] ⟨#Footnote1⟩
382
383
384       Use df <source-dir> to determine the source mount and then use  findmnt
385       -o TARGET,PROPAGATION <source-mount-dir> to determine propagation prop‐
386       erties of source mount, if findmnt utility is not available, the source
387       mount  point  can  be  determined  by  looking  at  the  mount entry in
388       /proc/self/mountinfo. Look at optional fields and see if  any  propaga‐
389       tion  properties  are  specified.   shared:X means the mount is shared,
390       master:X means the mount is slave and if nothing is  there  that  means
391       the mount is private. [1] ⟨#Footnote1⟩
392
393
394       To  change  propagation  properties of a mount point use the mount com‐
395       mand. For example, to bind mount the source  directory  /foo  do  mount
396       --bind /foo /foo and mount --make-private --make-shared /foo. This will
397       convert /foo into a shared mount point.  The propagation properties  of
398       the  source  mount  can  be  changed directly. For instance if / is the
399       source mount for /foo, then use mount --make-shared / to convert / into
400       a shared mount.
401
402
403       --workingdir directory
404
405
406       Temporarily  set  the working directory for the running process. Unlike
407       buildah config --workingdir, the workingdir will not persist  to  later
408       calls to buildah run or the built image.
409
410
411       NOTE:  End parsing of options with the -- option, so that other options
412       can be passed to the command inside of the container.
413
414

EXAMPLE

416       buildah run containerID -- ps -auxw
417
418
419       buildah run --hostname myhost containerID -- ps -auxw
420
421
422       buildah run containerID -- sh -c 'echo $PATH'
423
424
425       buildah run --runtime-flag log-format=json containerID /bin/bash
426
427
428       buildah run --runtime-flag debug containerID /bin/bash
429
430
431       buildah run --tty containerID /bin/bash
432
433
434       buildah run --tty=false containerID ls /
435
436
437       buildah run --volume /path/on/host:/path/in/container:ro,z  containerID
438       sh
439
440
441       buildah run -v /path/on/host:/path/in/container:z,U containerID sh
442
443
444       buildah   run  --mount  type=bind,src=/tmp/on:host,dst=/in:container,ro
445       containerID sh
446
447

SEE ALSO

449       buildah(1),    buildah-from(1),    buildah-config(1),    namespaces(7),
450       pid_namespaces(7), crun(1), runc(8)
451
452

FOOTNOTES

454       1:  The  Buildah  project  is committed to inclusivity, a core value of
455       open source. The master and slave mount  propagation  terminology  used
456       here is problematic and divisive, and should be changed. However, these
457       terms are currently used within the Linux kernel and must be used as-is
458       at  this  time. When the kernel maintainers rectify this usage, Buildah
459       will follow suit immediately.
460
461
462
463buildah                           March 2017                    buildah-run(1)
Impressum