.nh .TH buildah-run "1" "March 2017" "buildah" .SH NAME .PP buildah-run - Run a command inside of the container. .SH SYNOPSIS .PP \fBbuildah run\fP [\fIoptions\fP] [\fB--\fP] \fIcontainer\fP \fIcommand\fP .SH DESCRIPTION .PP Launches a container and runs the specified command in that container using the container's root filesystem as a root filesystem, using configuration settings inherited from the container's image or as specified using previous calls to the \fIbuildah config\fP command. To execute \fIbuildah run\fP within an interactive shell, specify the --tty option. .SH OPTIONS .PP \fB--add-history\fP .PP Add an entry to the history which will note what command is being invoked. Defaults to false. .PP Note: You can also override the default value of --add-history by setting the BUILDAH_HISTORY environment variable. \fBexport BUILDAH_HISTORY=true\fR .PP \fB--cap-add\fP=\fICAP_xxx\fP .PP Add the specified capability to the set of capabilities which will be granted to the specified command. Certain capabilities are granted by default; this option can be used to add more beyond the defaults, which may have been modified by \fB--cap-add\fP and \fB--cap-drop\fP options used with the \fIbuildah from\fP invocation which created the container. .PP \fB--cap-drop\fP=\fICAP_xxx\fP .PP Drop the specified capability from the set of capabilities which will be granted to the specified command. The CAP_CHOWN, CAP_DAC_OVERRIDE, CAP_FOWNER, CAP_FSETID, CAP_KILL, CAP_NET_BIND_SERVICE, CAP_SETFCAP, CAP_SETGID, CAP_SETPCAP, and CAP_SETUID capabilities are granted by default; this option can be used to remove them from the defaults, which may have been modified by \fB--cap-add\fP and \fB--cap-drop\fP options used with the \fIbuildah from\fP invocation which created the container. The list of default capabilities is managed in containers.conf(5). .PP If a capability is specified to both the \fB--cap-add\fP and \fB--cap-drop\fP options, it will be dropped, regardless of the order in which the options were given. .PP \fB--cgroupns\fP \fIhow\fP .PP Sets the configuration for the cgroup namespaces for the container. The configured value can be "" (the empty string) or "private" to indicate that a new cgroup namespace should be created, or it can be "host" to indicate that the cgroup namespace in which \fBbuildah\fR itself is being run should be reused. .PP \fB--contextdir\fP \fIdirectory\fP .PP Allows setting context directory for current RUN invocation. Specifying a context directory causes RUN context to consider context directory as root directory for specified source in \fB--mount\fR of type 'bind'. .PP \fB--env\fP, \fB-e\fP \fIenv=value\fP .PP Temporarily add a value (e.g. env=\fIvalue\fP) to the environment for the running process. Unlike \fBbuildah config --env\fR, the environment will not persist to later calls to \fBbuildah run\fR or to the built image. Can be used multiple times. .PP \fB--hostname\fP .PP Set the hostname inside of the running container. .PP \fB--ipc\fP \fIhow\fP .PP Sets the configuration for the IPC namespaces for the container. The configured value can be "" (the empty string) or "private" to indicate that a new IPC namespace should be created, or it can be "host" to indicate that the IPC namespace in which \fBbuildah\fR itself is being run should be reused, or it can be the path to an IPC namespace which is already in use by another process. .PP \fB--isolation\fP \fItype\fP .PP Controls what type of isolation is used for running the process. Recognized types include \fIoci\fP (OCI-compatible runtime, the default), \fIrootless\fP (OCI-compatible runtime invoked using a modified configuration, with \fI--no-new-keyring\fP added to its \fIcreate\fP invocation, reusing the host's network and UTS namespaces, and creating private IPC, PID, mount, and user namespaces; the default for unprivileged users), and \fIchroot\fP (an internal wrapper that leans more toward chroot(1) than container technology, reusing the host's control group, network, IPC, and PID namespaces, and creating private mount and UTS namespaces, and creating user namespaces only when they're required for ID mapping). .PP Note: You can also override the default isolation type by setting the BUILDAH_ISOLATION environment variable. \fBexport BUILDAH_ISOLATION=oci\fR .PP \fB--mount\fP=\fItype=TYPE,TYPE-SPECIFIC-OPTION[,...]\fP .PP Attach a filesystem mount to the container .PP Current supported mount TYPES are bind, cache, secret and tmpfs. [1] \[la]#Footnote1\[ra] .EX e.g. type=bind,source=/path/on/host,destination=/path/in/container type=tmpfs,tmpfs-size=512M,destination=/path/in/container type=cache,target=/path/in/container Common Options: · src, source: mount source spec for bind and volume. Mandatory for bind. If `from` is specified, `src` is the subpath in the `from` field. · dst, destination, target: mount destination spec. · ro, read-only: true or false (default). Options specific to bind: · bind-propagation: shared, slave, private, rshared, rslave, or rprivate(default). See also mount(2). . bind-nonrecursive: do not setup a recursive bind mount. By default it is recursive. · from: stage or image name for the root of the source. Defaults to the build context. · z: Set shared SELinux label on mounted destination. Use if SELinux is enabled on host machine. · Z: Set private SELinux label on mounted destination. Use if SELinux is enabled on host machine. Options specific to tmpfs: · tmpfs-size: Size of the tmpfs mount in bytes. Unlimited by default in Linux. · tmpfs-mode: File mode of the tmpfs in octal. (e.g. 700 or 0700.) Defaults to 1777 in Linux. · tmpcopyup: Path that is shadowed by the tmpfs mount is recursively copied up to the tmpfs itself. Options specific to secret: · id: the identifier for the secret passed into the `buildah bud --secret` or `podman build --secret` command. Options specific to cache: · id: Create a separate cache directory for a particular id. · mode: File mode for new cache directory in octal. Default 0755. · ro, readonly: read only cache if set. · uid: uid for cache directory. · gid: gid for cache directory. · from: stage name for the root of the source. Defaults to host cache directory. · z: Set shared SELinux label on mounted destination. Enabled by default if SELinux is enabled on the host machine. · Z: Set private SELinux label on mounted destination. Use if SELinux is enabled on host machine. .EE .PP \fB--network\fP, \fB--net\fP=\fImode\fP .PP Sets the configuration for the network namespace for the container. .PP Valid \fImode\fP values are: .RS .IP \(bu 2 \fBnone\fP: no networking. Invalid if using \fB--dns\fP, \fB--dns-opt\fP, or \fB--dns-search\fP; .IP \(bu 2 \fBhost\fP: use the host network stack. Note: the host mode gives the container full access to local system services such as D-bus and is therefore considered insecure; .IP \(bu 2 \fBns:\fP\fIpath\fP: path to a network namespace to join; .IP \(bu 2 \fBprivate\fP: create a new namespace for the container (default) .IP \(bu 2 \fB\fP: Join the network with the given name or ID, e.g. use \fB--network mynet\fR to join the network with the name mynet. Only supported for rootful users. .IP \(bu 2 \fBslirp4netns[:OPTIONS,...]\fP: use \fBslirp4netns\fP(1) to create a user network stack. This is the default for rootless containers. It is possible to specify these additional options, they can also be set with \fBnetwork_cmd_options\fR in containers.conf: .RS .IP \(bu 2 \fBallow_host_loopback=true|false\fP: Allow slirp4netns to reach the host loopback IP (default is 10.0.2.2 or the second IP from slirp4netns cidr subnet when changed, see the cidr option below). The default is false. .IP \(bu 2 \fBmtu=MTU\fP: Specify the MTU to use for this network. (Default is \fB65520\fR). .IP \(bu 2 \fBcidr=CIDR\fP: Specify ip range to use for this network. (Default is \fB10.0.2.0/24\fR). .IP \(bu 2 \fBenable_ipv6=true|false\fP: Enable IPv6. Default is true. (Required for \fBoutbound_addr6\fR). .IP \(bu 2 \fBoutbound_addr=INTERFACE\fP: Specify the outbound interface slirp binds to (ipv4 traffic only). .IP \(bu 2 \fBoutbound_addr=IPv4\fP: Specify the outbound ipv4 address slirp binds to. .IP \(bu 2 \fBoutbound_addr6=INTERFACE\fP: Specify the outbound interface slirp binds to (ipv6 traffic only). .IP \(bu 2 \fBoutbound_addr6=IPv6\fP: Specify the outbound ipv6 address slirp binds to. .RE .IP \(bu 2 \fBpasta[:OPTIONS,...]\fP: use \fBpasta\fP(1) to create a user-mode networking stack. .br This is only supported in rootless mode. .br By default, IPv4 and IPv6 addresses and routes, as well as the pod interface name, are copied from the host. If port forwarding isn't configured, ports are forwarded dynamically as services are bound on either side (init namespace or container namespace). Port forwarding preserves the original source IP address. Options described in pasta(1) can be specified as comma-separated arguments. .br In terms of pasta(1) options, \fB--config-net\fP is given by default, in order to configure networking when the container is started, and \fB--no-map-gw\fP is also assumed by default, to avoid direct access from container to host using the gateway address. The latter can be overridden by passing \fB--map-gw\fP in the pasta-specific options (despite not being an actual pasta(1) option). .br Also, \fB-t none\fP and \fB-u none\fP are passed to disable automatic port forwarding based on bound ports. Similarly, \fB-T none\fP and \fB-U none\fP are given to disable the same functionality from container to host. .br Some examples: .RS .IP \(bu 2 \fBpasta:--map-gw\fP: Allow the container to directly reach the host using the gateway address. .IP \(bu 2 \fBpasta:--mtu,1500\fP: Specify a 1500 bytes MTU for the \fItap\fP interface in the container. .IP \(bu 2 \fBpasta:--ipv4-only,-a,10.0.2.0,-n,24,-g,10.0.2.2,--dns-forward,10.0.2.3,-m,1500,--no-ndp,--no-dhcpv6,--no-dhcp\fP, equivalent to default slirp4netns(1) options: disable IPv6, assign \fB10.0.2.0/24\fR to the \fBtap0\fR interface in the container, with gateway \fB10.0.2.3\fR, enable DNS forwarder reachable at \fB10.0.2.3\fR, set MTU to 1500 bytes, disable NDP, DHCPv6 and DHCP support. .IP \(bu 2 \fBpasta:-I,tap0,--ipv4-only,-a,10.0.2.0,-n,24,-g,10.0.2.2,--dns-forward,10.0.2.3,--no-ndp,--no-dhcpv6,--no-dhcp\fP, equivalent to default slirp4netns(1) options with Podman overrides: same as above, but leave the MTU to 65520 bytes .IP \(bu 2 \fBpasta:-t,auto,-u,auto,-T,auto,-U,auto\fP: enable automatic port forwarding based on observed bound ports from both host and container sides .IP \(bu 2 \fBpasta:-T,5201\fP: enable forwarding of TCP port 5201 from container to host, using the loopback interface instead of the tap interface for improved performance .RE .RE .PP \fB--no-hostname\fP .PP Do not create the \fI/etc/hostname\fP file in the container for RUN instructions. .PP By default, Buildah manages the \fI/etc/hostname\fP file, adding the container's own hostname. When the \fB--no-hostname\fP option is set, the image's \fI/etc/hostname\fP will be preserved unmodified if it exists. .PP \fB--no-hosts\fP .PP Do not create the \fI/etc/hosts\fP file in the container for RUN instructions. .PP By default, Buildah manages \fI/etc/hosts\fP, adding the container's own IP address. \fB--no-hosts\fP disables this, and the image's \fI/etc/hosts\fP will be preserved unmodified. .PP \fB--no-pivot\fP .PP Do not use pivot root to jail process inside rootfs. This should be used whenever the rootfs is on top of a ramdisk. .PP Note: You can make this option the default by setting the BUILDAH_NOPIVOT environment variable. \fBexport BUILDAH_NOPIVOT=true\fR .PP \fB--pid\fP \fIhow\fP .PP Sets the configuration for the PID namespace for the container. The configured value can be "" (the empty string) or "private" to indicate that a new PID namespace should be created, or it can be "host" to indicate that the PID namespace in which \fBbuildah\fR itself is being run should be reused, or it can be the path to a PID namespace which is already in use by another process. .PP \fB--runtime\fP \fIpath\fP .PP The \fIpath\fP to an alternate OCI-compatible runtime. Default is \fBrunc\fR, or \fBcrun\fR when machine is configured to use cgroups V2. .PP Note: You can also override the default runtime by setting the BUILDAH_RUNTIME environment variable. \fBexport BUILDAH_RUNTIME=/usr/bin/crun\fR .PP \fB--runtime-flag\fP \fIflag\fP .PP Adds global flags for the container runtime. To list the supported flags, please consult the manpages of the selected container runtime. Note: Do not pass the leading \fB--\fR to the flag. To pass the runc flag \fB--log-format json\fR to buildah run, the option given would be \fB--runtime-flag log-format=json\fR\&. .PP \fB--tty\fP, \fB--terminal\fP, \fB-t\fP .PP By default a pseudo-TTY is allocated only when buildah's standard input is attached to a pseudo-TTY. Setting the \fB--tty\fR option to \fBtrue\fR will cause a pseudo-TTY to be allocated inside the container connecting the user's "terminal" with the stdin and stdout stream of the container. Setting the \fB--tty\fR option to \fBfalse\fR will prevent the pseudo-TTY from being allocated. .PP \fB--user\fP \fIuser\fP[:\fIgroup\fP] .PP Set the \fIuser\fP to be used for running the command in the container. The user can be specified as a user name or UID, optionally followed by a group name or GID, separated by a colon (':'). If names are used, the container should include entries for those names in its \fI/etc/passwd\fP and \fI/etc/group\fP files. .PP \fB--uts\fP \fIhow\fP .PP Sets the configuration for the UTS namespace for the container. The configured value can be "" (the empty string) or "private" to indicate that a new UTS namespace should be created, or it can be "host" to indicate that the UTS namespace in which \fBbuildah\fR itself is being run should be reused, or it can be the path to a UTS namespace which is already in use by another process. .PP \fB--volume\fP, \fB-v\fP \fIsource\fP:\fIdestination\fP:\fIoptions\fP .PP Create a bind mount. If you specify, \fB-v /HOST-DIR:/CONTAINER-DIR\fR, Buildah bind mounts \fB/HOST-DIR\fR in the host to \fB/CONTAINER-DIR\fR in the Buildah container. The \fBOPTIONS\fR are a comma delimited list and can be: [1] \[la]#Footnote1\[ra] .RS .IP \(bu 2 [rw|ro] .IP \(bu 2 [U] .IP \(bu 2 [z|Z] .IP \(bu 2 [\fB[r]shared\fR|\fB[r]slave\fR|\fB[r]private\fR] .RE .PP The \fBCONTAINER-DIR\fR must be an absolute path such as \fB/src/docs\fR\&. The \fBHOST-DIR\fR must be an absolute path as well. Buildah bind-mounts the \fBHOST-DIR\fR to the path you specify. For example, if you supply \fB/foo\fR as the host path, Buildah copies the contents of \fB/foo\fR to the container filesystem on the host and bind mounts that into the container. .PP You can specify multiple \fB-v\fP options to mount one or more mounts to a container. .PP \fBWrite Protected Volume Mounts\fR .PP You can add the \fB:ro\fR or \fB:rw\fR suffix to a volume to mount it read-only or read-write mode, respectively. By default, the volumes are mounted read-write. See examples. .PP \fBChowning Volume Mounts\fR .PP By default, Buildah does not change the owner and group of source volume directories mounted into containers. If a container is created in a new user namespace, the UID and GID in the container may correspond to another UID and GID on the host. .PP The \fB:U\fR suffix tells Buildah to use the correct host UID and GID based on the UID and GID within the container, to change the owner and group of the source volume. .PP \fBLabeling Volume Mounts\fR .PP Labeling systems like SELinux require that proper labels are placed on volume content mounted into a container. Without a label, the security system might prevent the processes running inside the container from using the content. By default, Buildah does not change the labels set by the OS. .PP To change a label in the container context, you can add either of two suffixes \fB:z\fR or \fB:Z\fR to the volume mount. These suffixes tell Buildah to relabel file objects on the shared volumes. The \fBz\fR option tells Buildah that two containers share the volume content. As a result, Buildah labels the content with a shared content label. Shared volume labels allow all containers to read/write content. The \fBZ\fR option tells Buildah to label the content with a private unshared label. Only the current container can use a private volume. .PP By default bind mounted volumes are \fBprivate\fR\&. That means any mounts done inside container will not be visible on the host and vice versa. This behavior can be changed by specifying a volume mount propagation property. .PP When the mount propagation policy is set to \fBshared\fR, any mounts completed inside the container on that volume will be visible to both the host and container. When the mount propagation policy is set to \fBslave\fR, one way mount propagation is enabled and any mounts completed on the host for that volume will be visible only inside of the container. To control the mount propagation property of the volume use the \fB:[r]shared\fR, \fB:[r]slave\fR or \fB:[r]private\fR propagation flag. The propagation property can be specified only for bind mounted volumes and not for internal volumes or named volumes. For mount propagation to work on the source mount point (the mount point where source dir is mounted on) it has to have the right propagation properties. For shared volumes, the source mount point has to be shared. And for slave volumes, the source mount has to be either shared or slave. [1] \[la]#Footnote1\[ra] .PP Use \fBdf \fR to determine the source mount and then use \fBfindmnt -o TARGET,PROPAGATION \fR to determine propagation properties of source mount, if \fBfindmnt\fR utility is not available, the source mount point can be determined by looking at the mount entry in \fB/proc/self/mountinfo\fR\&. Look at \fBoptional fields\fR and see if any propagation properties are specified. \fBshared:X\fR means the mount is \fBshared\fR, \fBmaster:X\fR means the mount is \fBslave\fR and if nothing is there that means the mount is \fBprivate\fR\&. [1] \[la]#Footnote1\[ra] .PP To change propagation properties of a mount point use the \fBmount\fR command. For example, to bind mount the source directory \fB/foo\fR do \fBmount --bind /foo /foo\fR and \fBmount --make-private --make-shared /foo\fR\&. This will convert /foo into a \fBshared\fR mount point. The propagation properties of the source mount can be changed directly. For instance if \fB/\fR is the source mount for \fB/foo\fR, then use \fBmount --make-shared /\fR to convert \fB/\fR into a \fBshared\fR mount. .PP \fB--workingdir\fP \fIdirectory\fP .PP Temporarily set the working \fIdirectory\fP for the running process. Unlike \fBbuildah config --workingdir\fR, the workingdir will not persist to later calls to \fBbuildah run\fR or the built image. .PP NOTE: End parsing of options with the \fB--\fR option, so that other options can be passed to the command inside of the container. .SH EXAMPLE .PP buildah run containerID -- ps -auxw .PP buildah run --hostname myhost containerID -- ps -auxw .PP buildah run containerID -- sh -c 'echo $PATH' .PP buildah run --runtime-flag log-format=json containerID /bin/bash .PP buildah run --runtime-flag debug containerID /bin/bash .PP buildah run --tty containerID /bin/bash .PP buildah run --tty=false containerID ls / .PP buildah run --volume /path/on/host:/path/in/container:ro,z containerID sh .PP buildah run -v /path/on/host:/path/in/container:z,U containerID sh .PP buildah run --mount type=bind,src=/tmp/on:host,dst=/in:container,ro containerID sh .SH SEE ALSO .PP buildah(1), buildah-from(1), buildah-config(1), namespaces(7), pid_namespaces(7), crun(1), runc(8), containers.conf(5) .SH FOOTNOTES .PP 1: The Buildah project is committed to inclusivity, a core value of open source. The \fBmaster\fR and \fBslave\fR mount propagation terminology used here is problematic and divisive, and should be changed. However, these terms are currently used within the Linux kernel and must be used as-is at this time. When the kernel maintainers rectify this usage, Buildah will follow suit immediately.