2021-08-25 02:03:02 +08:00
# buildah-build "1" "April 2017" "buildah"
2017-04-14 04:23:31 +08:00
## NAME
2021-08-25 02:03:02 +08:00
buildah\-build - Build an image using instructions from Containerfiles
2017-04-14 04:23:31 +08:00
## SYNOPSIS
2019-09-16 01:29:56 +08:00
2021-08-25 02:03:02 +08:00
**buildah build** [*options*] [*context*]
2018-06-30 03:39:36 +08:00
2019-08-12 21:10:14 +08:00
**buildah bud** [*options*] [*context*]
2018-06-30 03:39:36 +08:00
2017-04-14 04:23:31 +08:00
## DESCRIPTION
2019-09-16 01:29:56 +08:00
Builds an image using instructions from one or more Containerfiles or Dockerfiles and a specified
build context directory. A Containerfile uses the same syntax as a Dockerfile internally. For this
document, a file referred to as a Containerfile can be a file named either 'Containerfile' or 'Dockerfile'.
2018-05-15 20:03:58 +08:00
2019-09-16 01:29:56 +08:00
The build context directory can be specified as the http(s) URL of an archive, git repository or Containerfile.
2018-05-15 20:03:58 +08:00
2019-09-16 01:29:56 +08:00
If no context directory is specified, then Buildah will assume the current working directory as build context, which should contain a Containerfile.
2019-08-12 21:10:14 +08:00
2021-05-19 21:05:47 +08:00
Containerfiles ending with a ".in" suffix will be preprocessed via cpp(1). This can be useful to decompose Containerfiles into several reusable parts that can be used via CPP's ** #include ** directive. Notice, a Containerfile.in file can still be used by other tools when manually preprocessing them via `cpp -E` . Any comments ( Lines beginning with `#` ) in included Containerfile(s) that are not preprocess commands, will be printed as warnings during builds.
2018-08-01 18:31:02 +08:00
2018-05-15 20:03:58 +08:00
When the URL is an archive, the contents of the URL is downloaded to a temporary location and extracted before execution.
2019-09-16 01:29:56 +08:00
When the URL is a Containerfile, the file is downloaded to a temporary location.
2018-05-15 20:03:58 +08:00
2022-08-01 11:51:19 +08:00
When a Git repository is set as the URL, the repository is cloned locally and then used as the build context. A non-default branch (or commit ID) and subdirectory of the cloned git repository can be used by including their names at the end of the URL in the form `myrepo.git#mybranch:subdir` , `myrepo.git#mycommit:subdir` , or `myrepo.git#:subdir` if the subdirectory should be used from the default branch.
2017-04-14 04:23:31 +08:00
## OPTIONS
2018-02-14 03:58:56 +08:00
**--add-host**=[]
Add a custom host-to-IP mapping (host:ip)
2022-03-08 04:44:14 +08:00
Add a line to /etc/hosts. The format is hostname:ip. The ** --add-host** option can be set multiple times. Conflicts with the --no-hosts option.
2018-02-14 03:58:56 +08:00
2025-05-29 23:22:52 +08:00
Instead of an IP address, the special flag host-gateway can be given. This resolves to an IP address the container can use to connect to the host. The IP address chosen depends on your network setup, thus there's no guarantee that Buildah can determine the host-gateway address automatically, which will then cause Buildah to fail with an error message. You can overwrite this IP address using the host_containers_internal_ip option in containers.conf.
The host-gateway address is also used by Buildah to automatically add the host.containers.internal and host.docker.internal hostnames to /etc/hosts. You can prevent that by either giving the --no-hosts option, or by setting host_containers_internal_ip="none" in containers.conf. If no host-gateway address was configured manually and Buildah fails to determine the IP address automatically, Buildah will silently skip adding these internal hostnames to /etc/hosts. If Buildah is running in a virtual machine using podman machine (this includes Mac and Windows hosts), Buildah will silently skip adding the internal hostnames to /etc/hosts, unless an IP address was configured manually; the internal hostnames are resolved by the gvproxy DNS resolver instead.
Buildah will use the /etc/hosts file of the host as a basis by default, i.e. any hostname present in this file will also be present in the /etc/hosts file of the container. A different base file can be configured using the base_hosts_file config in containers.conf
2021-09-28 05:26:01 +08:00
**--all-platforms**
Instead of building for a set of platforms specified using the ** --platform** option, inspect the build's base images, and build for all of the platforms for which they are all available. Stages that use *scratch* as a starting point can not be inspected, so at least one non-*scratch* stage must be present for detection to work usefully.
2022-05-03 06:30:46 +08:00
**--annotation** *annotation[=value]*
2018-05-23 00:05:18 +08:00
Add an image *annotation* (e.g. annotation=*value*) to the image metadata. Can be used multiple times.
2022-05-05 03:58:45 +08:00
If *annotation* is named, but neither `=` nor a `value` is provided, then the *annotation* is set to an empty value.
2018-05-23 00:05:18 +08:00
Note: this information is not present in Docker image formats, so it is discarded when writing images in Docker formats.
2020-01-20 19:31:09 +08:00
**--arch**="ARCH"
2021-08-11 06:11:15 +08:00
Set the ARCH of the image to be built, and that of the base image to be pulled, if the build uses one, to the provided value instead of using the architecture of the host. (Examples: arm, arm64, 386, amd64, ppc64le, s390x)
2020-01-20 19:31:09 +08:00
2017-11-16 04:18:48 +08:00
**--authfile** *path*
2024-01-26 04:50:33 +08:00
Path of the authentication file. Default is ${XDG_RUNTIME_DIR}/containers/auth.json. See containers-auth.json(5) for more information. This file is created using `buildah login` .
2021-04-30 03:36:15 +08:00
2017-11-21 23:08:12 +08:00
If the authorization state is not found there, $HOME/.docker/config.json is checked, which is set using `docker login` .
2017-11-16 04:18:48 +08:00
2020-11-06 09:56:22 +08:00
Note: You can also override the default path of the authentication file by setting the REGISTRY\_AUTH\_FILE
environment variable. `export REGISTRY_AUTH_FILE=path`
2017-09-22 17:32:10 +08:00
**--build-arg** *arg=value*
Specifies a build argument and its value, which will be interpolated in
2019-09-16 01:29:56 +08:00
instructions read from the Containerfiles in the same way that environment
2017-09-22 17:32:10 +08:00
variables are, but which will not be added to environment variable list in the
resulting image's configuration.
2020-11-25 09:04:52 +08:00
Please refer to the [BUILD TIME VARIABLES ](#build-time-variables ) section for the
list of variables that can be overridden within the Containerfile at run time.
2023-03-25 18:32:47 +08:00
**--build-arg-file** *path*
2023-03-27 00:21:47 +08:00
Specifies a file containing lines of build arguments of the form arg=value. The suggested file name is argfile.conf.
2023-03-25 18:32:47 +08:00
2023-03-27 00:21:47 +08:00
Comment lines beginning with `#` are ignored, along with blank lines. All others should be of the `arg=value` format passed to `--build-arg` .
2023-03-25 18:32:47 +08:00
2023-03-27 00:21:47 +08:00
If several arguments are provided via the `--build-arg-file` and `--build-arg` options, the build arguments will be merged across all of the provided files and command line arguments.
2023-03-25 18:32:47 +08:00
2023-03-29 05:48:33 +08:00
Any file provided in a `--build-arg-file` option will be read before the arguments supplied via the `--build-arg` option.
2023-03-25 18:32:47 +08:00
2023-03-27 00:21:47 +08:00
When a given argument name is specified several times, the last instance is the one that is passed to the resulting builds. This means `--build-arg` values always override those in a `--build-arg-file` .
2023-03-25 18:32:47 +08:00
2022-05-10 18:11:37 +08:00
**--build-context** *name=value*
Specify an additional build context using its short name and its location. Additional
build contexts can be referenced in the same manner as we access different stages in `COPY`
instruction.
Valid values could be:
* Local directory – e.g. --build-context project2=../path/to/project2/src
* HTTP URL to a tarball – e.g. --build-context src=https://example.org/releases/src.tar
* Container image – specified with a container-image:// prefix, e.g. --build-context alpine=container-image://alpine:3.15, (also accepts docker://, docker-image://)
On the Containerfile side, you can reference the build context on all commands that accept the “from” parameter.
Here’ s how that might look:
```Dockerfile
FROM [name]
COPY --from=[name] ...
RUN --mount=from=[name] …
```
The value of `[name]` is matched with the following priority order:
* Named build context defined with --build-context [name]=..
* Stage defined with AS [name] inside Containerfile
* Image [name], either local or in a remote registry
2018-05-06 19:42:01 +08:00
**--cache-from**
2022-12-05 14:29:19 +08:00
Repository to utilize as a potential list of cache sources. When specified, Buildah will try to look for
cache images in the specified repositories and will attempt to pull cache images instead of actually
2022-07-18 13:47:55 +08:00
executing the build steps locally. Buildah will only attempt to pull previously cached images if they
are considered as valid cache hits.
2022-12-05 14:29:19 +08:00
Use the `--cache-to` option to populate a remote repository or repositories with cache content.
2022-07-18 13:47:55 +08:00
Example
```bash
# populate a cache and also consult it
buildah build -t test --layers --cache-to registry/myrepo/cache --cache-from registry/myrepo/cache .
```
Note: `--cache-from` option is ignored unless `--layers` is specified.
2023-03-06 13:48:23 +08:00
Note: Buildah's `--cache-from` option is designed differently than Docker and BuildKit's `--cache-from` option. Buildah's
distributed cache mechanism pulls intermediate images from the remote registry itself, unlike Docker and BuildKit where
the intermediate image is stored in the image itself. Buildah's approach is similar to kaniko, which
does not inflate the size of the original image with intermediate images. Also, intermediate images can truly be
kept distributed across one or more remote registries using Buildah's caching mechanism.
2022-07-18 13:47:55 +08:00
**--cache-to**
2022-12-05 14:29:19 +08:00
Set this flag to specify list of remote repositories that will be used to store cache images. Buildah will attempt to
push newly built cache image to the remote repositories.
2022-07-18 13:47:55 +08:00
Note: Use the `--cache-from` option in order to use cache content in a remote repository.
Example
```bash
# populate a cache and also consult it
buildah build -t test --layers --cache-to registry/myrepo/cache --cache-from registry/myrepo/cache .
```
Note: `--cache-to` option is ignored unless `--layers` is specified.
2018-05-06 19:42:01 +08:00
2023-03-06 13:48:23 +08:00
Note: Buildah's `--cache-to` option is designed differently than Docker and BuildKit's `--cache-to` option. Buildah's
distributed cache mechanism push intermediate images to the remote registry itself, unlike Docker and BuildKit where
the intermediate image is stored in the image itself. Buildah's approach is similar to kaniko, which
does not inflate the size of the original image with intermediate images. Also, intermediate images can truly be
kept distributed across one or more remote registries using Buildah's caching mechanism.
2022-08-04 15:14:39 +08:00
**--cache-ttl** *duration*
Limit the use of cached images to only consider images with created timestamps less than *duration* ago.
For example if `--cache-ttl=1h` is specified, Buildah will only consider intermediate cache images which are created
under the duration of one hour, and intermediate cache images outside this duration will be ignored.
2022-09-15 16:42:19 +08:00
Note: Setting `--cache-ttl=0` manually is equivalent to using `--no-cache` in the implementation since this would
effectively mean that user is not willing to use cache at all.
2018-06-05 05:36:26 +08:00
**--cap-add**=*CAP\_xxx*
When executing RUN instructions, run the command specified in the instruction
with the specified capability added to its capability set.
Certain capabilities are granted by default; this option can be used to add
more.
**--cap-drop**=*CAP\_xxx*
When executing RUN instructions, run the command specified in the instruction
with the specified capability removed from its capability set.
2023-02-14 13:26:49 +08:00
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. The list of default capabilities is managed in containers.conf(5).
2018-06-05 05:36:26 +08:00
If a capability is specified to both the ** --cap-add** and ** --cap-drop**
options, it will be dropped, regardless of the order in which the options were
given.
2018-01-31 08:19:30 +08:00
**--cert-dir** *path*
2024-07-20 02:07:25 +08:00
Use certificates at *path* (\*.crt, \*.cert, \*.key) to connect to the registry
and retrieve contents from HTTPS locations for ADD instructions.
2020-09-09 16:25:25 +08:00
The default certificates directory is _/etc/containers/certs.d_ .
2018-01-31 08:19:30 +08:00
2018-02-14 03:58:56 +08:00
**--cgroup-parent**=""
2025-04-18 04:25:13 +08:00
Path to cgroups under which the cgroup for RUN instructions will be created. If the path is not absolute, the path is considered to be relative to the cgroups path of the init process. Cgroups will be created if they do not already exist.
2018-02-14 03:58:56 +08:00
2021-11-19 04:20:50 +08:00
**--cgroupns** *how*
Sets the configuration for cgroup namespaces when handling `RUN` instructions.
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 `buildah` itself is being run should be reused.
2024-06-07 04:32:13 +08:00
**--compat-volumes**
Handle directories marked using the VOLUME instruction (both in this build, and
those inherited from base images) such that their contents can only be modified
by ADD and COPY instructions. Any changes made in those locations by RUN
instructions will be reverted. Before the introduction of this option, this
behavior was the default, but it is now disabled by default.
2018-04-27 00:35:16 +08:00
**--compress**
This option is added to be aligned with other containers CLIs.
2018-04-14 06:20:25 +08:00
Buildah doesn't send a copy of the context directory to a daemon or a remote server.
2018-04-27 00:35:16 +08:00
Thus, compressing the data before sending it is irrelevant to Buildah.
2022-05-14 18:58:34 +08:00
**--cpp-flag**=""
Set additional flags to pass to the C Preprocessor cpp(1).
Containerfiles ending with a ".in" suffix will be preprocessed via cpp(1). This option can be used to pass additional flags to cpp.
Note: You can also set default CPPFLAGS by setting the BUILDAH\_CPPFLAGS
environment variable (e.g., `export BUILDAH_CPPFLAGS="-DDEBUG"` ).
2018-02-14 03:58:56 +08:00
**--cpu-period**=*0*
2020-11-06 09:56:22 +08:00
Set the CPU period for the Completely Fair Scheduler (CFS), which is a
duration in microseconds. Once the container's CPU quota is used up, it will
not be scheduled to run until the current period ends. Defaults to 100000
microseconds.
2018-02-14 03:58:56 +08:00
2020-11-06 09:56:22 +08:00
On some systems, changing the CPU limits may not be allowed for non-root
users. For more details, see
2021-06-23 22:44:11 +08:00
https://github.com/containers/podman/blob/main/troubleshooting.md#26-running-containers-with-cpu-limits-fails-with-a-permissions-error
2018-02-14 03:58:56 +08:00
**--cpu-quota**=*0*
Limit the CPU CFS (Completely Fair Scheduler) quota
Limit the container's CPU usage. By default, containers run with the full
2022-01-26 04:55:55 +08:00
CPU resource. This flag tells the kernel to restrict the container's CPU usage
2018-02-14 03:58:56 +08:00
to the quota you specify.
2020-11-06 09:56:22 +08:00
On some systems, changing the CPU limits may not be allowed for non-root
users. For more details, see
2021-06-23 22:44:11 +08:00
https://github.com/containers/podman/blob/main/troubleshooting.md#26-running-containers-with-cpu-limits-fails-with-a-permissions-error
2020-11-06 09:56:22 +08:00
New CI check: xref --help vs man pages
Run 'buildah --help', recursively against all subcommands,
then cross-reference the results against docs/buildah*.md.
Report differences in subcommands and/or flags.
The majority of the changes in this PR are trivial (see
below) but a handful may be controversial and require
careful review:
* Making 'bud' the default output of 'buildah help',
with 'build-using-dockerfile' as an alias. This is
the inverse of the situation until now: buildah
would list build-using-dockerfile as the primary
name. The man page, OTOH, lists 'bud'. The source
file name is 'bud'. I suspect that most people
type 'bud'. So, for consistency, I choose to make
'bud' the default visible command.
* add --encryption-key and --encrypt-layer documentation
to buildah-commit.md, and --encrypt-layer to -push.md.
Please double-check the wording here.
* remove --notruncate from buildah-images.md. The option
does not exist (although there is a TODO comment in
the code). If it should exist, it is left to the
reader to implement. I would humbly suggest that this
is a good idea, for consistency with buildah containers.
* remove --shm-size from buildah-pull.md. The option
does not exist, and I suspect this was a copy-paste error.
* remove --security-opt from run.go. It was unimplemented
and undocumented.
* remove --userns-[gu]id-map from buildah-bud.md. These
are global options, not bud options, and are documented
well enough in buildah.bud.
Trivial (IMO) changes:
* split options in man pages, from '**--foo, -f**'
to '**--foo**, **-f**'. This conforms with the style
used in podman man pages.
* add missing one-letter aliases (usually "-q", "-a")
* add missing man page entries for some easy options
* sort out-of-order subcommand listings in man pages
Finally, do note that this is a copy-and-alter duplicate of the
original script in podman, and that is horrible. In an ideal
world I would've been able to refactor the podman version into
something usable on both repos (and then more). It turns out the
differences in man page format and in special-case handling are
too broad to let me do a clean refactor.
Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-09-21 22:51:19 +08:00
**--cpu-shares**, ** -c**=*0*
2018-02-14 03:58:56 +08:00
CPU shares (relative weight)
By default, all containers get the same proportion of CPU cycles. This proportion
can be modified by changing the container's CPU share weighting relative
to the weighting of all other running containers.
To modify the proportion from the default of 1024, use the ** --cpu-shares**
flag to set the weighting to 2 or higher.
The proportion will only apply when CPU-intensive processes are running.
When tasks in one container are idle, other containers can use the
left-over CPU time. The actual amount of CPU time will vary depending on
the number of containers running on the system.
For example, consider three containers, one has a cpu-share of 1024 and
two others have a cpu-share setting of 512. When processes in all three
containers attempt to use 100% of CPU, the first container would receive
50% of the total CPU time. If you add a fourth container with a cpu-share
of 1024, the first container only gets 33% of the CPU. The remaining containers
receive 16.5%, 16.5% and 33% of the CPU.
On a multi-core system, the shares of CPU time are distributed over all CPU
cores. Even if a container is limited to less than 100% of CPU time, it can
use 100% of each individual CPU core.
For example, consider a system with more than three cores. If you start one
container ** {C0}** with ** -c=512** running one process, and another container
**{C1}** with ** -c=1024** running two processes, this can result in the following
division of CPU shares:
PID container CPU CPU share
100 {C0} 0 100% of CPU0
101 {C1} 1 100% of CPU1
102 {C1} 2 100% of CPU2
**--cpuset-cpus**=""
CPUs in which to allow execution (0-3, 0,1)
**--cpuset-mems**=""
Memory nodes (MEMs) in which to allow execution (0-3, 0,1). Only effective on NUMA systems.
If you have four memory nodes on your system (0-3), use `--cpuset-mems=0,1`
then processes in your container will only use memory from the first
two memory nodes.
2025-06-21 03:05:20 +08:00
**--created-annotation**
Add an image *annotation* (see also ** --annotation**) to the image metadata
setting "org.opencontainers.image.created" to the current time, or to the
datestamp specified to the ** --source-date-epoch** or ** --timestamp** flag,
if either was used. If *false* , no such annotation will be present in the
written image.
Note: this information is not present in Docker image formats, so it is discarded when writing images in Docker formats.
2018-01-31 08:19:30 +08:00
**--creds** *creds*
The [username[:password]] to use to authenticate with the registry if required.
If one or both values are not supplied, a command line prompt will appear and the
value can be entered. The password is entered without echo.
2023-07-26 06:17:33 +08:00
**--cw** *options*
Produce an image suitable for use as a confidential workload running in a
trusted execution environment (TEE) using krun (i.e., *crun* built with the
libkrun feature enabled and invoked as *krun* ). Instead of the conventional
contents, the root filesystem of the image will contain an encrypted disk image
and configuration information for krun.
The value for *options* is a comma-separated list of key=value pairs, supplying
configuration information which is needed for producing the additional data
which will be included in the container image.
Recognized _keys_ are:
*attestation_url*: The location of a key broker / attestation server.
If a value is specified, the new image's workload ID, along with the passphrase
used to encrypt the disk image, will be registered with the server, and the
server's location will be stored in the container image.
At run-time, krun is expected to contact the server to retrieve the passphrase
using the workload ID, which is also stored in the container image.
If no value is specified, a *passphrase* value *must* be specified.
*cpus*: The number of virtual CPUs which the image expects to be run with at
run-time. If not specified, a default value will be supplied.
*firmware_library*: The location of the libkrunfw-sev shared library. If not
specified, `buildah` checks for its presence in a number of hard-coded
locations.
*memory*: The amount of memory which the image expects to be run with at
run-time, as a number of megabytes. If not specified, a default value will be
supplied.
*passphrase*: The passphrase to use to encrypt the disk image which will be
included in the container image.
If no value is specified, but an *attestation_url* value is specified, a
randomly-generated passphrase will be used.
The authors recommend setting an *attestation_url* but not a *passphrase* .
*slop*: Extra space to allocate for the disk image compared to the size of the
container image's contents, expressed either as a percentage (..%) or a size
value (bytes, or larger units if suffixes like KB or MB are present), or a sum
of two or more such specifications. If not specified, `buildah` guesses that
25% more space than the contents will be enough, but this option is provided in
case its guess is wrong.
*type*: The type of trusted execution environment (TEE) which the image should
be marked for use with. Accepted values are "SEV" (AMD Secure Encrypted
Virtualization - Encrypted State) and "SNP" (AMD Secure Encrypted
Virtualization - Secure Nested Paging). If not specified, defaults to "SNP".
*workload_id*: A workload identifier which will be recorded in the container
image, to be used at run-time for retrieving the passphrase which was used to
encrypt the disk image. If not specified, a semi-random value will be derived
from the base image's image ID.
2020-05-20 03:12:29 +08:00
**--decryption-key** *key[:passphrase]*
2020-04-02 02:15:56 +08:00
2020-08-11 17:28:41 +08:00
The [key[:passphrase]] to be used for decryption of images. Key can point to keys and/or certificates. Decryption will be tried with all keys. If the key is protected by a passphrase, it is required to be passed in the argument and omitted otherwise.
2020-04-02 02:15:56 +08:00
2019-09-07 03:07:18 +08:00
**--device**=*device*
2024-03-29 05:17:44 +08:00
Add a host device, or devices under a directory, to the environment of any
**RUN** instructions run during the build. The optional *permissions*
parameter can be used to specify device permissions, using any one or more of
2020-11-06 09:56:22 +08:00
**r** for read, **w** for write, and **m** for **mknod** (2).
Example: ** --device=/dev/sdc:/dev/xvdc:rwm**.
2024-03-29 05:17:44 +08:00
Note: if _host-device_ is a symbolic link then it will be resolved first.
2020-11-06 09:56:22 +08:00
The container will only store the major and minor numbers of the host device.
2024-03-29 05:17:44 +08:00
The device to share can also be specified using a Container Device Interface
(CDI) specification (https://github.com/cncf-tags/container-device-interface).
2020-11-06 09:56:22 +08:00
Note: if the user only has access rights via a group, accessing the device
from inside a rootless container will fail. The **crun** (1) runtime offers a
workaround for this by adding the option ** --annotation run.oci.keep_original_groups=1**.
2018-11-17 11:23:01 +08:00
New CI check: xref --help vs man pages
Run 'buildah --help', recursively against all subcommands,
then cross-reference the results against docs/buildah*.md.
Report differences in subcommands and/or flags.
The majority of the changes in this PR are trivial (see
below) but a handful may be controversial and require
careful review:
* Making 'bud' the default output of 'buildah help',
with 'build-using-dockerfile' as an alias. This is
the inverse of the situation until now: buildah
would list build-using-dockerfile as the primary
name. The man page, OTOH, lists 'bud'. The source
file name is 'bud'. I suspect that most people
type 'bud'. So, for consistency, I choose to make
'bud' the default visible command.
* add --encryption-key and --encrypt-layer documentation
to buildah-commit.md, and --encrypt-layer to -push.md.
Please double-check the wording here.
* remove --notruncate from buildah-images.md. The option
does not exist (although there is a TODO comment in
the code). If it should exist, it is left to the
reader to implement. I would humbly suggest that this
is a good idea, for consistency with buildah containers.
* remove --shm-size from buildah-pull.md. The option
does not exist, and I suspect this was a copy-paste error.
* remove --security-opt from run.go. It was unimplemented
and undocumented.
* remove --userns-[gu]id-map from buildah-bud.md. These
are global options, not bud options, and are documented
well enough in buildah.bud.
Trivial (IMO) changes:
* split options in man pages, from '**--foo, -f**'
to '**--foo**, **-f**'. This conforms with the style
used in podman man pages.
* add missing one-letter aliases (usually "-q", "-a")
* add missing man page entries for some easy options
* sort out-of-order subcommand listings in man pages
Finally, do note that this is a copy-and-alter duplicate of the
original script in podman, and that is horrible. In an ideal
world I would've been able to refactor the podman version into
something usable on both repos (and then more). It turns out the
differences in man page format and in special-case handling are
too broad to let me do a clean refactor.
Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-09-21 22:51:19 +08:00
**--disable-compression**, ** -D**
2021-08-11 06:11:15 +08:00
2018-06-06 22:41:40 +08:00
Don't compress filesystem layers when building the image unless it is required
by the location where the image is being written. This is the default setting,
because image layers are compressed automatically when they are pushed to
registries, and images being written to local storage would only need to be
decompressed again to be stored. Compression can be forced in all cases by
specifying ** --disable-compression=false**.
2018-11-17 11:23:01 +08:00
2018-06-07 02:50:42 +08:00
**--disable-content-trust**
2021-10-09 20:26:55 +08:00
This is a Docker specific option to disable image verification to a Container
2018-06-07 02:50:42 +08:00
registry and is not supported by Buildah. This flag is a NOOP and provided
2019-11-17 00:31:41 +08:00
solely for scripting compatibility.
2018-06-07 02:50:42 +08:00
2019-04-07 00:03:58 +08:00
**--dns**=[]
2022-09-16 02:26:37 +08:00
Set custom DNS servers. Invalid if using ** --dns** with ** --network=none**.
2019-04-07 00:03:58 +08:00
2019-06-07 03:44:23 +08:00
This option can be used to override the DNS configuration passed to the container. Typically this is necessary when the host DNS configuration is invalid for the container (e.g., 127.0.0.1). When this is the case the `--dns` flag is necessary for every run.
The special value **none** can be specified to disable creation of /etc/resolv.conf in the container by Buildah. The /etc/resolv.conf file in the image will be used without changes.
2019-04-07 00:03:58 +08:00
**--dns-option**=[]
2022-09-16 02:26:37 +08:00
Set custom DNS options. Invalid if using ** --dns-option** with ** --network=none**.
2019-04-07 00:03:58 +08:00
**--dns-search**=[]
2022-09-16 02:26:37 +08:00
Set custom DNS search domains. Invalid if using ** --dns-search** with ** --network=none**.
2019-04-07 00:03:58 +08:00
2022-05-03 06:24:59 +08:00
**--env** *env[=value]*
Add a value (e.g. env=*value*) to the built image. Can be used multiple times.
If neither `=` nor a `*value*` are specified, but *env* is set in the current
environment, the value from the current environment will be added to the image.
2023-01-10 03:41:21 +08:00
The value of *env* can be overridden by ENV instructions in the Containerfile.
2022-05-03 06:24:59 +08:00
To remove an environment variable from the built image, use the `--unsetenv`
option.
New CI check: xref --help vs man pages
Run 'buildah --help', recursively against all subcommands,
then cross-reference the results against docs/buildah*.md.
Report differences in subcommands and/or flags.
The majority of the changes in this PR are trivial (see
below) but a handful may be controversial and require
careful review:
* Making 'bud' the default output of 'buildah help',
with 'build-using-dockerfile' as an alias. This is
the inverse of the situation until now: buildah
would list build-using-dockerfile as the primary
name. The man page, OTOH, lists 'bud'. The source
file name is 'bud'. I suspect that most people
type 'bud'. So, for consistency, I choose to make
'bud' the default visible command.
* add --encryption-key and --encrypt-layer documentation
to buildah-commit.md, and --encrypt-layer to -push.md.
Please double-check the wording here.
* remove --notruncate from buildah-images.md. The option
does not exist (although there is a TODO comment in
the code). If it should exist, it is left to the
reader to implement. I would humbly suggest that this
is a good idea, for consistency with buildah containers.
* remove --shm-size from buildah-pull.md. The option
does not exist, and I suspect this was a copy-paste error.
* remove --security-opt from run.go. It was unimplemented
and undocumented.
* remove --userns-[gu]id-map from buildah-bud.md. These
are global options, not bud options, and are documented
well enough in buildah.bud.
Trivial (IMO) changes:
* split options in man pages, from '**--foo, -f**'
to '**--foo**, **-f**'. This conforms with the style
used in podman man pages.
* add missing one-letter aliases (usually "-q", "-a")
* add missing man page entries for some easy options
* sort out-of-order subcommand listings in man pages
Finally, do note that this is a copy-and-alter duplicate of the
original script in podman, and that is horrible. In an ideal
world I would've been able to refactor the podman version into
something usable on both repos (and then more). It turns out the
differences in man page format and in special-case handling are
too broad to let me do a clean refactor.
Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-09-21 22:51:19 +08:00
**--file**, ** -f** *Containerfile*
2017-04-14 04:23:31 +08:00
2019-09-16 01:29:56 +08:00
Specifies a Containerfile which contains instructions for building the image,
2017-04-14 04:23:31 +08:00
either a local file or an **http** or **https** URL. If more than one
2019-09-16 01:29:56 +08:00
Containerfile is specified, *FROM* instructions will only be accepted from the
2023-01-30 19:51:38 +08:00
last specified file.
2017-04-14 04:23:31 +08:00
2019-09-16 01:29:56 +08:00
If a local file is specified as the Containerfile and it does not exist, the
2018-08-03 07:48:44 +08:00
context directory will be prepended to the local file value.
2017-04-14 04:23:31 +08:00
2019-09-16 01:29:56 +08:00
If you specify `-f -` , the Containerfile contents will be read from stdin.
2018-07-27 22:48:16 +08:00
2018-06-14 02:09:45 +08:00
**--force-rm** *bool-value*
2018-05-06 19:16:11 +08:00
2019-03-18 22:10:04 +08:00
Always remove intermediate containers after a build, even if the build fails (default false).
2018-05-06 19:16:11 +08:00
2017-09-22 17:32:10 +08:00
**--format**
Control the format for the built image's manifest and configuration data.
Recognized formats include *oci* (OCI image-spec v1.0, the default) and
*docker* (version 2, using schema format 2 for the manifest).
2018-06-15 03:41:05 +08:00
Note: You can also override the default format by setting the BUILDAH\_FORMAT
2018-06-01 22:26:34 +08:00
environment variable. `export BUILDAH_FORMAT=docker`
2020-11-25 09:04:52 +08:00
**--from**
Overrides the first `FROM` instruction within the Containerfile. If there are multiple
FROM instructions in a Containerfile, only the first is changed.
2022-12-22 03:51:59 +08:00
**--group-add**=*group* | *keep-groups*
Assign additional groups to the primary user running within the container
process.
- `keep-groups` is a special flag that tells Buildah to keep the supplementary
group access.
Allows container to use the user's supplementary group access. If file systems
or devices are only accessible by the rootless user's group, this flag tells the
OCI runtime to pass the group access into the container. Currently only
available with the `crun` OCI runtime. Note: `keep-groups` is exclusive, other
groups cannot be specified with this flag.
2022-03-24 20:03:06 +08:00
**--help**, ** -h**
2020-11-06 09:56:22 +08:00
Print usage statement
2022-06-22 18:48:00 +08:00
**--hooks-dir** *path*
2023-08-28 15:56:05 +08:00
Each `*.json` file in the path configures a hook for buildah build containers. For more details on the syntax of the JSON files and the semantics of hook injection, see oci-hooks(5). Buildah currently support both the 1.0.0 and 0.1.0 hook schemas, although the 0.1.0 schema is deprecated.
2022-06-22 18:48:00 +08:00
2023-08-28 15:56:05 +08:00
This option may be set multiple times; paths from later options have higher precedence (oci-hooks(5) discusses directory precedence).
2022-06-22 18:48:00 +08:00
For the annotation conditions, buildah uses any annotations set in the generated OCI configuration.
For the bind-mount conditions, only mounts explicitly requested by the caller via --volume are considered. Bind mounts that buildah inserts by default (e.g. /dev/shm) are not considered.
If --hooks-dir is unset for root callers, Buildah will currently default to /usr/share/containers/oci/hooks.d and /etc/containers/oci/hooks.d in order of increasing precedence. Using these defaults is deprecated, and callers should migrate to explicitly setting --hooks-dir.
2020-11-06 09:56:22 +08:00
**--http-proxy**=true
2019-04-13 07:03:39 +08:00
By default proxy environment variables are passed into the container if set
for the buildah process. This can be disabled by setting the `--http-proxy`
option to `false` . The environment variables passed in include `http_proxy` ,
`https_proxy` , `ftp_proxy` , `no_proxy` , and also the upper case versions of
those.
2022-04-04 13:37:01 +08:00
**--identity-label** *bool-value*
2025-05-15 04:57:01 +08:00
Adds a label `io.buildah.version` with its value set to the version of buildah
which built the image (default true unless `--timestamp` or
`--source-date-epoch` is used).
2022-04-04 13:37:01 +08:00
2022-03-24 20:03:06 +08:00
**--ignorefile** *file*
Path to an alternative .containerignore (.dockerignore) file.
2018-04-25 22:00:46 +08:00
**--iidfile** *ImageIDfile*
2021-08-11 06:11:15 +08:00
Write the built image's ID to the file. When `--platform` is specified more
than once, attempting to use this option will trigger an error.
2018-04-25 22:00:46 +08:00
2025-06-03 00:14:55 +08:00
**--inherit-annotations** *bool-value*
Inherit the annotations from the base image or base stages. (default true).
2025-06-21 03:05:20 +08:00
Use cases which set this flag to *false* may need to do the same for the
**--created-annotation** flag.
2025-06-03 00:14:55 +08:00
2023-09-23 00:28:44 +08:00
**--inherit-labels** *bool-value*
Inherit the labels from the base image or base stages. (default true).
2018-03-13 01:53:12 +08:00
**--ipc** *how*
Sets the configuration for IPC namespaces when handling `RUN` instructions.
The configured value can be "" (the empty string) or "container" to indicate
that a new IPC namespace should be created, or it can be "host" to indicate
that the IPC namespace in which `buildah` 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.
2018-05-12 01:00:14 +08:00
**--isolation** *type*
2018-04-26 20:36:27 +08:00
2018-07-19 02:59:20 +08:00
Controls what type of isolation is used for running processes as part of `RUN`
instructions. Recognized types include *oci* (OCI-compatible runtime, the
default), *rootless* (OCI-compatible runtime invoked using a modified
2021-06-03 04:22:28 +08:00
configuration, with *--no-new-keyring* added to its *create* invocation,
reusing the host's network and UTS namespaces, and creating private IPC, PID,
mount, and user namespaces; the default for unprivileged users), and *chroot*
(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).
2018-05-12 01:00:14 +08:00
Note: You can also override the default isolation type by setting the
BUILDAH\_ISOLATION environment variable. `export BUILDAH_ISOLATION=oci`
2018-04-26 20:36:27 +08:00
2020-06-22 16:53:02 +08:00
**--jobs** *N*
Run up to N concurrent stages in parallel. If the number of jobs is greater than 1,
stdin will be read from /dev/null. If 0 is specified, then there is
2021-08-11 06:11:15 +08:00
no limit on the number of jobs that run in parallel.
2020-06-22 16:53:02 +08:00
2022-05-03 06:30:46 +08:00
**--label** *label[=value]*
2018-05-17 02:13:12 +08:00
Add an image *label* (e.g. label=*value*) to the image metadata. Can be used multiple times.
2022-05-05 03:58:45 +08:00
If *label* is named, but neither `=` nor a `value` is provided, then the *label* is set to an empty value.
2018-05-17 02:13:12 +08:00
2020-11-06 09:56:22 +08:00
Users can set a special LABEL **io.containers.capabilities=CAP1,CAP2,CAP3** in
2022-01-26 04:55:55 +08:00
a Containerfile that specifies the list of Linux capabilities required for the
2020-11-06 09:56:22 +08:00
container to run properly. This label specified in a container image tells
2024-07-30 02:49:57 +08:00
container engines, like Podman, which recognize this label to run the container with just these
2020-11-20 22:52:51 +08:00
capabilities. The container engine launches the container with just the specified
capabilities, as long as this list of capabilities is a subset of the default
list.
2018-07-04 02:38:26 +08:00
2020-11-20 22:52:51 +08:00
If the specified capabilities are not in the default set, container engines
should print an error message and will run the container with the default
capabilities.
2018-07-04 02:38:26 +08:00
2023-08-02 15:29:19 +08:00
**--layer-label** *label[=value]*
2024-07-30 02:49:57 +08:00
Add an intermediate image *label* (e.g. label=*value*) to the metadata in intermediate images, i.e., any images built for
non-final stages and for non-final instructions in stages when ** --layers** is **true** . It can be used multiple times.
2023-08-02 15:29:19 +08:00
If *label* is named, but neither `=` nor a `value` is provided, then the *label* is set to an empty value.
2018-06-14 02:09:45 +08:00
**--layers** *bool-value*
2018-06-09 00:55:46 +08:00
Cache intermediate images during the build process (Default is `false` ).
2018-06-15 03:41:05 +08:00
Note: You can also override the default value of layers by setting the BUILDAH\_LAYERS
2018-06-09 00:55:46 +08:00
environment variable. `export BUILDAH_LAYERS=true`
2018-06-06 01:53:39 +08:00
**--logfile** *filename*
Log output which would be sent to standard output and standard error to the
specified file instead of to standard output and standard error.
2022-06-06 14:33:15 +08:00
**--logsplit** *bool-value*
If --logfile and --platform is specified following flag allows end-users to split log file for each
platform into different files with naming convention as `${logfile}_${platform-os}_${platform-arch}` .
2021-10-28 21:50:13 +08:00
**--manifest** *listName*
2020-12-30 20:16:24 +08:00
2021-08-11 06:11:15 +08:00
Name of the manifest list to which the built image will be added. Creates the
manifest list if it does not exist. This option is useful for building multi
architecture images.
2021-10-28 21:50:13 +08:00
If _listName_ does not include a registry name component, the registry name
*localhost* will be prepended to the list name.
2020-12-30 20:16:24 +08:00
New CI check: xref --help vs man pages
Run 'buildah --help', recursively against all subcommands,
then cross-reference the results against docs/buildah*.md.
Report differences in subcommands and/or flags.
The majority of the changes in this PR are trivial (see
below) but a handful may be controversial and require
careful review:
* Making 'bud' the default output of 'buildah help',
with 'build-using-dockerfile' as an alias. This is
the inverse of the situation until now: buildah
would list build-using-dockerfile as the primary
name. The man page, OTOH, lists 'bud'. The source
file name is 'bud'. I suspect that most people
type 'bud'. So, for consistency, I choose to make
'bud' the default visible command.
* add --encryption-key and --encrypt-layer documentation
to buildah-commit.md, and --encrypt-layer to -push.md.
Please double-check the wording here.
* remove --notruncate from buildah-images.md. The option
does not exist (although there is a TODO comment in
the code). If it should exist, it is left to the
reader to implement. I would humbly suggest that this
is a good idea, for consistency with buildah containers.
* remove --shm-size from buildah-pull.md. The option
does not exist, and I suspect this was a copy-paste error.
* remove --security-opt from run.go. It was unimplemented
and undocumented.
* remove --userns-[gu]id-map from buildah-bud.md. These
are global options, not bud options, and are documented
well enough in buildah.bud.
Trivial (IMO) changes:
* split options in man pages, from '**--foo, -f**'
to '**--foo**, **-f**'. This conforms with the style
used in podman man pages.
* add missing one-letter aliases (usually "-q", "-a")
* add missing man page entries for some easy options
* sort out-of-order subcommand listings in man pages
Finally, do note that this is a copy-and-alter duplicate of the
original script in podman, and that is horrible. In an ideal
world I would've been able to refactor the podman version into
something usable on both repos (and then more). It turns out the
differences in man page format and in special-case handling are
too broad to let me do a clean refactor.
Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-09-21 22:51:19 +08:00
**--memory**, ** -m**=""
2018-02-14 03:58:56 +08:00
Memory limit (format: < number > [< unit > ], where unit = b, k, m or g)
Allows you to constrain the memory available to a container. If the host
supports swap memory, then the ** -m** memory setting can be larger than physical
RAM. If a limit of 0 is specified (not using ** -m**), the container's memory is
not limited. The actual limit may be rounded up to a multiple of the operating
system's page size (the value would be very large, that's millions of trillions).
**--memory-swap**="LIMIT"
A limit value equal to memory plus swap. Must be used with the ** -m**
(**--memory**) flag. The swap `LIMIT` should always be larger than ** -m**
(**--memory**) value. By default, the swap `LIMIT` will be set to double
the value of --memory.
The format of `LIMIT` is `<number>[<unit>]` . Unit can be `b` (bytes),
`k` (kilobytes), `m` (megabytes), or `g` (gigabytes). If you don't specify a
unit, `b` is used. Set LIMIT to `-1` to enable unlimited swap.
2020-08-04 22:13:17 +08:00
**--network**, ** --net**=*mode*
2018-03-13 01:53:12 +08:00
Sets the configuration for network namespaces when handling `RUN` instructions.
2020-08-04 22:13:17 +08:00
Valid _mode_ values are:
2022-09-16 02:26:37 +08:00
- **none**: no networking. Invalid if using ** --dns**, ** --dns-opt**, or ** --dns-search**;
2020-11-20 22:52:51 +08:00
- **host**: 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;
2020-08-04 22:13:17 +08:00
- **ns:**_path_: path to a network namespace to join;
2022-01-19 23:43:02 +08:00
- **private**: create a new namespace for the container (default)
- **\<network name|ID\>**: Join the network with the given name or ID, e.g. use `--network mynet` to join the network with the name mynet. Only supported for rootful users.
2023-06-22 21:31:32 +08:00
- **slirp4netns[:OPTIONS,...]**: use **slirp4netns** (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 `network_cmd_options` in containers.conf:
- **allow_host_loopback=true|false**: 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.
- **mtu=MTU**: Specify the MTU to use for this network. (Default is `65520` ).
- **cidr=CIDR**: Specify ip range to use for this network. (Default is `10.0.2.0/24` ).
- **enable_ipv6=true|false**: Enable IPv6. Default is true. (Required for `outbound_addr6` ).
- **outbound_addr=INTERFACE**: Specify the outbound interface slirp binds to (ipv4 traffic only).
- **outbound_addr=IPv4**: Specify the outbound ipv4 address slirp binds to.
- **outbound_addr6=INTERFACE**: Specify the outbound interface slirp binds to (ipv6 traffic only).
- **outbound_addr6=IPv6**: Specify the outbound ipv6 address slirp binds to.
2023-06-23 00:14:50 +08:00
- **pasta[:OPTIONS,...]**: use **pasta** (1) to create a user-mode networking
stack. \
This is only supported in rootless mode. \
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. \
In terms of pasta(1) options, ** --config-net** is given by default, in
order to configure networking when the container is started, and
** --no-map-gw** is also assumed by default, to avoid direct access from
container to host using the gateway address. The latter can be overridden
by passing ** --map-gw** in the pasta-specific options (despite not being an
actual pasta(1) option). \
Also, ** -t none** and ** -u none** are passed to disable
automatic port forwarding based on bound ports. Similarly, ** -T none** and
** -U none** are given to disable the same functionality from container to
host. \
Some examples:
- **pasta:--map-gw**: Allow the container to directly reach the host using the
gateway address.
- **pasta:--mtu,1500**: Specify a 1500 bytes MTU for the _tap_ interface in
the container.
- **pasta:--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**,
equivalent to default slirp4netns(1) options: disable IPv6, assign
`10.0.2.0/24` to the `tap0` interface in the container, with gateway
`10.0.2.3` , enable DNS forwarder reachable at `10.0.2.3` , set MTU to 1500
bytes, disable NDP, DHCPv6 and DHCP support.
- **pasta:-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**,
equivalent to default slirp4netns(1) options with Podman overrides: same as
above, but leave the MTU to 65520 bytes
- **pasta:-t,auto,-u,auto,-T,auto,-U,auto**: enable automatic port forwarding
based on observed bound ports from both host and container sides
- **pasta:-T,5201**: enable forwarding of TCP port 5201 from container to
host, using the loopback interface instead of the tap interface for improved
performance
2018-03-13 01:53:12 +08:00
2018-06-15 03:41:05 +08:00
**--no-cache**
2018-05-06 19:42:01 +08:00
2018-06-09 00:55:46 +08:00
Do not use existing cached images for the container build. Build from the start with a new set of cached layers.
2018-05-06 19:42:01 +08:00
2023-10-25 07:43:56 +08:00
**--no-hostname**
Do not create the _/etc/hostname_ file in the container for RUN instructions.
By default, Buildah manages the _/etc/hostname_ file, adding the container's own hostname. When the ** --no-hostname** option is set, the image's _/etc/hostname_ will be preserved unmodified if it exists.
2022-03-08 04:44:14 +08:00
**--no-hosts**
2023-10-25 07:43:56 +08:00
Do not create the _/etc/hosts_ file in the container for RUN instructions.
2022-03-08 04:44:14 +08:00
By default, Buildah manages _/etc/hosts_ , adding the container's own IP address.
**--no-hosts** disables this, and the image's _/etc/hosts_ will be preserved unmodified. Conflicts with the --add-host option.
2022-06-01 15:59:52 +08:00
**--omit-history** *bool-value*
Omit build history information in the built image. (default false).
This option is useful for the cases where end users explicitly
want to set `--omit-history` to omit the optional `History` from
built images or when working with images built using build tools that
do not include `History` information in their images.
2020-01-20 19:31:09 +08:00
**--os**="OS"
2021-08-11 06:11:15 +08:00
Set the OS of the image to be built, and that of the base image to be pulled, if the build uses one, instead of using the current operating system of the host.
2020-01-20 19:31:09 +08:00
2022-05-03 06:37:36 +08:00
**--os-feature** *feature*
Set the name of a required operating system *feature* for the image which will
be built. By default, if the image is not based on *scratch* , the base image's
required OS feature list is kept, if the base image specified any. This option
is typically only meaningful when the image's OS is Windows.
If *feature* has a trailing `-` , then the *feature* is removed from the set of
required features which will be listed in the image.
**--os-version** *version*
Set the exact required operating system *version* for the image which will be
built. By default, if the image is not based on *scratch* , the base image's
required OS version is kept, if the base image specified one. This option is
typically only meaningful when the image's OS is Windows, and is typically set in
Windows base images, so using this option is usually unnecessary.
2022-04-29 21:39:42 +08:00
**--output**, ** -o**=""
2025-04-30 05:04:20 +08:00
Additional output (format: type=local,dest=path)
2022-04-29 21:39:42 +08:00
2025-04-30 05:04:20 +08:00
The --output (or -o) option supplements the default behavior of building a
container image by allowing users to export the image's contents as files on
the local filesystem, which can be useful for generating local binaries, code
generation, etc.
2022-04-29 21:39:42 +08:00
2025-04-30 05:04:20 +08:00
The value for --output is a comma-separated sequence of key=value pairs,
defining the output type and options.
2022-04-29 21:39:42 +08:00
Supported _keys_ are:
2025-04-30 05:04:20 +08:00
**dest** : Destination for exported output. Can be set to `-` to indicate standard output, or to an absolute or relative path.
**type** : Defines the type of output to be written. Must be one of the values listed below.
2022-04-29 21:39:42 +08:00
Valid _type_ values are:
2025-04-30 05:04:20 +08:00
**local** : write the resulting build files to a directory on the client-side.
**tar** : write the resulting files as a single tarball (.tar).
2022-04-29 21:39:42 +08:00
2025-04-30 05:04:20 +08:00
Alternatively, instead of a comma-separated sequence, the value of ** --output**
can be just the destination (in the `**dest**` format) (e.g. `--output
some-path`, `--output -` ), and the **type** will be inferred to be **tar** if
the output destination is `-` , and **local** otherwise.
2022-04-29 21:39:42 +08:00
2025-04-30 05:04:20 +08:00
Timestamps on the output contents will be set to exactly match the value
specified using the ** --timestamp** flag, or to exactly match the value
specified for the ** --source-date-epoch** flag, if either are specified.
Note that the ** --tag** option can also be used to write the image to any location described by `containers-transports(5)` .
2023-12-17 20:00:58 +08:00
2018-03-13 01:53:12 +08:00
**--pid** *how*
Sets the configuration for PID namespaces when handling `RUN` instructions.
2020-08-04 22:13:17 +08:00
The configured value can be "" (the empty string) or "private" to indicate
2018-03-13 01:53:12 +08:00
that a new PID namespace should be created, or it can be "host" to indicate
that the PID namespace in which `buildah` 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.
bud: teach --platform to take a list
Add a pkg/parse.PlatformsFromOptions() which understands a "variant"
value as an optional third value in an OS/ARCH[/VARIANT] argument value,
which accepts a comma-separated list of them, and which returns a list
of platforms.
Teach "from" and "pull" about the --platform option and add integration
tests for them, warning if --platform was given multiple values.
Add a define.BuildOptions.JobSemaphore which an imagebuildah executor
will use in preference to one that it might allocate for itself.
In main(), allocate a JobSemaphore if the number of jobs is not 0 (which
we treat as "unlimited", and continue to allow executors to do).
In addManifest(), take a lock on the manifest list's image ID so that we
don't overwrite changes that another thread might be making while we're
attempting to make changes to it. In main(), create an empty list if
the list doesn't already exist before we start down this path, so that
we don't get two threads trying to create that manifest list at the same
time later on. Two processes could still try to create the same list
twice, but it's an incremental improvement.
Finally, if we've been given multiple platforms to build for, run their
builds concurrently and gather up their results.
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2021-06-22 22:52:49 +08:00
**--platform**="OS/ARCH[/VARIANT]"
2018-12-08 22:51:01 +08:00
bud: teach --platform to take a list
Add a pkg/parse.PlatformsFromOptions() which understands a "variant"
value as an optional third value in an OS/ARCH[/VARIANT] argument value,
which accepts a comma-separated list of them, and which returns a list
of platforms.
Teach "from" and "pull" about the --platform option and add integration
tests for them, warning if --platform was given multiple values.
Add a define.BuildOptions.JobSemaphore which an imagebuildah executor
will use in preference to one that it might allocate for itself.
In main(), allocate a JobSemaphore if the number of jobs is not 0 (which
we treat as "unlimited", and continue to allow executors to do).
In addManifest(), take a lock on the manifest list's image ID so that we
don't overwrite changes that another thread might be making while we're
attempting to make changes to it. In main(), create an empty list if
the list doesn't already exist before we start down this path, so that
we don't get two threads trying to create that manifest list at the same
time later on. Two processes could still try to create the same list
twice, but it's an incremental improvement.
Finally, if we've been given multiple platforms to build for, run their
builds concurrently and gather up their results.
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2021-06-22 22:52:49 +08:00
Set the OS/ARCH of the built image (and its base image, if your build uses one)
to the provided value instead of using the current operating system and
2023-04-25 17:46:47 +08:00
architecture of the host (for example `linux/arm` , `linux/arm64` , `linux/amd64` ).
2018-12-08 22:51:01 +08:00
bud: teach --platform to take a list
Add a pkg/parse.PlatformsFromOptions() which understands a "variant"
value as an optional third value in an OS/ARCH[/VARIANT] argument value,
which accepts a comma-separated list of them, and which returns a list
of platforms.
Teach "from" and "pull" about the --platform option and add integration
tests for them, warning if --platform was given multiple values.
Add a define.BuildOptions.JobSemaphore which an imagebuildah executor
will use in preference to one that it might allocate for itself.
In main(), allocate a JobSemaphore if the number of jobs is not 0 (which
we treat as "unlimited", and continue to allow executors to do).
In addManifest(), take a lock on the manifest list's image ID so that we
don't overwrite changes that another thread might be making while we're
attempting to make changes to it. In main(), create an empty list if
the list doesn't already exist before we start down this path, so that
we don't get two threads trying to create that manifest list at the same
time later on. Two processes could still try to create the same list
twice, but it's an incremental improvement.
Finally, if we've been given multiple platforms to build for, run their
builds concurrently and gather up their results.
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2021-06-22 22:52:49 +08:00
The `--platform` flag can be specified more than once, or given a
comma-separated list of values as its argument. When more than one platform is
specified, the `--manifest` option should be used instead of the `--tag`
option.
OS/ARCH pairs are those used by the Go Programming Language. In several cases
the ARCH value for a platform differs from one produced by other tools such as
the `arch` command. Valid OS and architecture name combinations are listed as
values for $GOOS and $GOARCH at https://golang.org/doc/install/source#environment,
and can also be found by running `go tool dist list` .
2023-04-13 19:02:33 +08:00
The `buildah build` command allows building images for all Linux architectures, even non-native architectures. When building images for a different architecture, the `RUN` instructions require emulation software installed on the host provided by packages like `qemu-user-static` . Note: it is always preferred to build images on the native architecture if possible.
bud: teach --platform to take a list
Add a pkg/parse.PlatformsFromOptions() which understands a "variant"
value as an optional third value in an OS/ARCH[/VARIANT] argument value,
which accepts a comma-separated list of them, and which returns a list
of platforms.
Teach "from" and "pull" about the --platform option and add integration
tests for them, warning if --platform was given multiple values.
Add a define.BuildOptions.JobSemaphore which an imagebuildah executor
will use in preference to one that it might allocate for itself.
In main(), allocate a JobSemaphore if the number of jobs is not 0 (which
we treat as "unlimited", and continue to allow executors to do).
In addManifest(), take a lock on the manifest list's image ID so that we
don't overwrite changes that another thread might be making while we're
attempting to make changes to it. In main(), create an empty list if
the list doesn't already exist before we start down this path, so that
we don't get two threads trying to create that manifest list at the same
time later on. Two processes could still try to create the same list
twice, but it's an incremental improvement.
Finally, if we've been given multiple platforms to build for, run their
builds concurrently and gather up their results.
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2021-06-22 22:52:49 +08:00
2021-10-09 22:43:09 +08:00
**NOTE:** The `--platform` option may not be used in combination with the `--arch` , `--os` , or `--variant` options.
2017-04-14 04:23:31 +08:00
**--pull**
2025-07-26 03:18:14 +08:00
Pull image policy. If not specified, the default is **missing** . If an explicit
**--pull** argument is provided without any value, use the **always** behavior.
2024-06-05 03:10:19 +08:00
- **always**: Pull base and SBOM scanner images from the registries listed in
registries.conf. Raise an error if a base or SBOM scanner image is not found
in the registries, even if an image with the same name is present locally.
- **missing**: SBOM scanner images only if they could not be found in the local
containers storage. Raise an error if no image could be found and the pull
fails.
- **never**: Do not pull base and SBOM scanner images from registries, use only
the local versions. Raise an error if the image is not present locally.
- **newer**: Pull base and SBOM scanner images from the registries listed in
registries.conf if newer. Raise an error if a base or SBOM scanner image is
not found in the registries when image with the same name is not present
locally.
2022-01-23 06:17:38 +08:00
New CI check: xref --help vs man pages
Run 'buildah --help', recursively against all subcommands,
then cross-reference the results against docs/buildah*.md.
Report differences in subcommands and/or flags.
The majority of the changes in this PR are trivial (see
below) but a handful may be controversial and require
careful review:
* Making 'bud' the default output of 'buildah help',
with 'build-using-dockerfile' as an alias. This is
the inverse of the situation until now: buildah
would list build-using-dockerfile as the primary
name. The man page, OTOH, lists 'bud'. The source
file name is 'bud'. I suspect that most people
type 'bud'. So, for consistency, I choose to make
'bud' the default visible command.
* add --encryption-key and --encrypt-layer documentation
to buildah-commit.md, and --encrypt-layer to -push.md.
Please double-check the wording here.
* remove --notruncate from buildah-images.md. The option
does not exist (although there is a TODO comment in
the code). If it should exist, it is left to the
reader to implement. I would humbly suggest that this
is a good idea, for consistency with buildah containers.
* remove --shm-size from buildah-pull.md. The option
does not exist, and I suspect this was a copy-paste error.
* remove --security-opt from run.go. It was unimplemented
and undocumented.
* remove --userns-[gu]id-map from buildah-bud.md. These
are global options, not bud options, and are documented
well enough in buildah.bud.
Trivial (IMO) changes:
* split options in man pages, from '**--foo, -f**'
to '**--foo**, **-f**'. This conforms with the style
used in podman man pages.
* add missing one-letter aliases (usually "-q", "-a")
* add missing man page entries for some easy options
* sort out-of-order subcommand listings in man pages
Finally, do note that this is a copy-and-alter duplicate of the
original script in podman, and that is horrible. In an ideal
world I would've been able to refactor the podman version into
something usable on both repos (and then more). It turns out the
differences in man page format and in special-case handling are
too broad to let me do a clean refactor.
Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-09-21 22:51:19 +08:00
**--quiet**, ** -q**
2017-04-14 04:23:31 +08:00
2017-09-22 17:32:10 +08:00
Suppress output messages which indicate which instruction is being processed,
and of progress when pulling images from a registry, and when writing the
output image.
2017-04-14 04:23:31 +08:00
2022-08-22 14:46:39 +08:00
**--retry** *attempts*
Number of times to retry in case of failure when performing push/pull of images to/from registry.
Defaults to `3` .
**--retry-delay** *duration*
Duration of delay between retry attempts in case of failure when performing push/pull of images to/from registry.
Defaults to `2s` .
2025-04-30 05:04:20 +08:00
**--rewrite-timestamp**
When generating new layers for the image, ensure that no newly added content
bears a timestamp later than the value used by the ** --source-date-epoch**
flag, if one was provided, by replacing any timestamps which are later than
that value, with that value.
2018-06-14 02:09:45 +08:00
**--rm** *bool-value*
2018-04-27 00:35:16 +08:00
2018-06-14 02:09:45 +08:00
Remove intermediate containers after a successful build (default true).
2018-04-27 00:35:16 +08:00
2017-04-14 04:23:31 +08:00
**--runtime** *path*
2017-04-13 05:20:42 +08:00
The *path* to an alternate OCI-compatible runtime, which will be used to run
2019-08-28 04:31:34 +08:00
commands specified by the **RUN** instruction. Default is `runc` , or `crun` when machine is configured to use cgroups V2.
2018-06-13 05:21:08 +08:00
2018-06-15 03:41:05 +08:00
Note: You can also override the default runtime by setting the BUILDAH\_RUNTIME
2019-08-28 04:31:34 +08:00
environment variable. `export BUILDAH_RUNTIME=/usr/bin/crun`
2017-04-14 04:23:31 +08:00
**--runtime-flag** *flag*
2024-01-28 20:25:10 +08:00
Adds global flags for the container runtime. To list the supported flags, please
2019-08-28 04:31:34 +08:00
consult the manpages of the selected container runtime.
2018-08-31 04:59:54 +08:00
2018-01-31 01:08:18 +08:00
Note: Do not pass the leading `--` to the flag. To pass the runc flag `--log-format json`
2021-08-25 02:03:02 +08:00
to buildah build, the option given would be `--runtime-flag log-format=json` .
2017-04-14 04:23:31 +08:00
2023-12-05 03:05:38 +08:00
**--sbom** *preset*
Generate SBOMs (Software Bills Of Materials) for the output image by scanning
the working container and build contexts using the named combination of scanner
image, scanner commands, and merge strategy. Must be specified with one or
more of ** --sbom-image-output**, ** --sbom-image-purl-output**, ** --sbom-output**,
and ** --sbom-purl-output**. Recognized presets, and the set of options which
they equate to:
- "syft", "syft-cyclonedx":
--sbom-scanner-image=ghcr.io/anchore/syft
--sbom-scanner-command="/syft scan -q dir:{ROOTFS} --output cyclonedx-json={OUTPUT}"
--sbom-scanner-command="/syft scan -q dir:{CONTEXT} --output cyclonedx-json={OUTPUT}"
--sbom-merge-strategy=merge-cyclonedx-by-component-name-and-version
- "syft-spdx":
--sbom-scanner-image=ghcr.io/anchore/syft
--sbom-scanner-command="/syft scan -q dir:{ROOTFS} --output spdx-json={OUTPUT}"
--sbom-scanner-command="/syft scan -q dir:{CONTEXT} --output spdx-json={OUTPUT}"
--sbom-merge-strategy=merge-spdx-by-package-name-and-versioninfo
- "trivy", "trivy-cyclonedx":
--sbom-scanner-image=ghcr.io/aquasecurity/trivy
--sbom-scanner-command="trivy filesystem -q {ROOTFS} --format cyclonedx --output {OUTPUT}"
--sbom-scanner-command="trivy filesystem -q {CONTEXT} --format cyclonedx --output {OUTPUT}"
--sbom-merge-strategy=merge-cyclonedx-by-component-name-and-version
- "trivy-spdx":
--sbom-scanner-image=ghcr.io/aquasecurity/trivy
--sbom-scanner-command="trivy filesystem -q {ROOTFS} --format spdx-json --output {OUTPUT}"
--sbom-scanner-command="trivy filesystem -q {CONTEXT} --format spdx-json --output {OUTPUT}"
--sbom-merge-strategy=merge-spdx-by-package-name-and-versioninfo
**--sbom-image-output** *path*
When generating SBOMs, store the generated SBOM in the specified path in the
output image. There is no default.
**--sbom-image-purl-output** *path*
When generating SBOMs, scan them for PURL ([package
URL](https://github.com/package-url/purl-spec/blob/master/PURL-SPECIFICATION.rst))
information, and save a list of found PURLs to the specified path in the output
image. There is no default.
**--sbom-merge-strategy** *method*
If more than one ** --sbom-scanner-command** value is being used, use the
specified method to merge the output from later commands with output from
earlier commands. Recognized values include:
- cat
Concatenate the files.
- merge-cyclonedx-by-component-name-and-version
Merge the "component" fields of JSON documents, ignoring values from
documents when the combination of their "name" and "version" values is
already present. Documents are processed in the order in which they are
generated, which is the order in which the commands that generate them
were specified.
- merge-spdx-by-package-name-and-versioninfo
Merge the "package" fields of JSON documents, ignoring values from
documents when the combination of their "name" and "versionInfo" values is
already present. Documents are processed in the order in which they are
generated, which is the order in which the commands that generate them
were specified.
**--sbom-output** *file*
When generating SBOMs, store the generated SBOM in the named file on the local
filesystem. There is no default.
**--sbom-purl-output** *file*
When generating SBOMs, scan them for PURL ([package
URL](https://github.com/package-url/purl-spec/blob/master/PURL-SPECIFICATION.rst))
information, and save a list of found PURLs to the named file in the local
filesystem. There is no default.
**--sbom-scanner-command** *image*
Generate SBOMs by running the specified command from the scanner image. If
multiple commands are specified, they are run in the order in which they are
specified. These text substitutions are performed:
- {ROOTFS}
The root of the built image's filesystem, bind mounted.
- {CONTEXT}
The build context and additional build contexts, bind mounted.
- {OUTPUT}
The name of a temporary output file, to be read and merged with others or copied elsewhere.
**--sbom-scanner-image** *image*
Generate SBOMs using the specified scanner image.
2024-10-17 05:09:41 +08:00
**--secret**=**id=id[,src=*envOrFile*][,env=ENV][,type=file|env]**
2021-08-11 06:11:15 +08:00
2021-04-17 06:21:31 +08:00
Pass secret information to be used in the Containerfile for building images
in a safe way that will not end up stored in the final image, or be seen in other stages.
2024-10-17 05:09:41 +08:00
The value of the secret will be read from an environment variable or file named
by the "id" option, or named by the "src" option if it is specified, or from an
2024-11-09 09:10:56 +08:00
environment variable specified by the "env" option.
2025-02-22 15:21:28 +08:00
The secret will be mounted in the container at `/run/secrets/<id>` by default.
2021-04-17 06:21:31 +08:00
To later use the secret, use the --mount flag in a `RUN` instruction within a `Containerfile` :
`RUN --mount=type=secret,id=mysecret cat /run/secrets/mysecret`
2024-10-17 05:09:41 +08:00
The location of the secret in the container can be overridden using the
"target", "dst", or "destination" option of the `RUN --mount` flag.
`RUN --mount=type=secret,id=mysecret,target=/run/secrets/myothersecret cat /run/secrets/myothersecret`
Note: changing the contents of secret files will not trigger a rebuild of layers that use said secrets.
2023-05-29 18:51:26 +08:00
2018-02-14 03:58:56 +08:00
**--security-opt**=[]
Security Options
2024-03-29 05:17:44 +08:00
"apparmor=unconfined" : Turn off apparmor confinement for the container
2020-11-06 09:56:22 +08:00
"apparmor=your-profile" : Set the apparmor confinement profile for the container
2024-03-29 05:17:44 +08:00
"label=user:USER" : Set the label user for the container
"label=role:ROLE" : Set the label role for the container
"label=type:TYPE" : Set the label type for the container
"label=level:LEVEL" : Set the label level for the container
"label=disable" : Turn off label confinement for the container
2024-12-18 23:47:40 +08:00
"mask=_/path/1:/path/2_": The paths to mask separated by a colon. A masked path cannot be accessed inside the container.
2024-03-29 05:17:44 +08:00
"no-new-privileges" : Disable container processes from gaining additional privileges
2018-02-14 03:58:56 +08:00
2024-03-29 05:17:44 +08:00
"seccomp=unconfined" : Turn off seccomp confinement for the container
"seccomp=profile.json : JSON configuration for a seccomp filter
2018-02-14 03:58:56 +08:00
2024-12-18 23:47:40 +08:00
"unmask=_ALL_ or _/path/1:/path/2_ , or shell expanded paths (/proc/*): Paths to unmask separated by a colon. If set to **ALL** , it unmasks all the paths that are masked or made read-only by default.
2025-05-15 03:14:24 +08:00
The default masked paths are ** /proc/acpi, /proc/interrupts, /proc/kcore, /proc/keys, /proc/latency_stats, /proc/sched_debug, /proc/scsi, /proc/timer_list, /proc/timer_stats, /sys/devices/virtual/powercap, /sys/firmware**, and ** /sys/fs/selinux**. The default paths that are read-only are ** /proc/asound**, ** /proc/bus**, ** /proc/fs**, ** /proc/irq**, ** /proc/sys**, and ** /proc/sysrq-trigger**.
2024-12-18 23:47:40 +08:00
2018-02-23 01:41:22 +08:00
**--shm-size**=""
Size of `/dev/shm` . The format is `<number><unit>` . `number` must be greater than `0` .
Unit is optional and can be `b` (bytes), `k` (kilobytes), `m` (megabytes), or `g` (gigabytes).
If you omit the unit, the system uses bytes. If you omit the size entirely, the system uses `64m` .
2020-01-16 01:23:38 +08:00
**--sign-by** *fingerprint*
Sign the built image using the GPG key that matches the specified fingerprint.
2022-09-15 18:00:23 +08:00
**--skip-unused-stages** *bool-value*
Skip stages in multi-stage builds which don't affect the target stage. (Default is `true` ).
2025-04-30 05:04:20 +08:00
**--source-date-epoch** *seconds*
Set the "created" timestamp for the built image to this number of seconds since
the epoch (Unix time 0, i.e., 00:00:00 UTC on 1 January 1970) (default is to
use the value set in the `SOURCE_DATE_EPOCH` environment variable, or the
current time if it is not set).
The "created" timestamp is written into the image's configuration and manifest
when the image is committed, so running the same build two different times
will ordinarily produce images with different sha256 hashes, even if no other
changes were made to the Containerfile and build context.
When this flag is set, a `SOURCE_DATE_EPOCH` build arg will provide its value
for a stage in which it is declared.
When this flag is set, the image configuration's "created" timestamp is always
set to the time specified, which should allow for identical images to be built
at different times using the same set of inputs.
When this flag is set, output written as specified to the ** --output** flag
will bear exactly the specified timestamp.
Conflicts with the similar ** --timestamp** flag, which also sets its specified
time on the contents of new layers.
2018-04-27 00:35:16 +08:00
**--squash**
2023-01-06 07:52:23 +08:00
Squash all layers, including those from base image(s), into one single layer. (Default is false).
By default, Buildah preserves existing base-image layers and adds only one new layer on a build.
The --layers option can be used to preserve intermediate build layers.
2018-04-27 00:35:16 +08:00
2021-07-26 14:07:23 +08:00
**--ssh**=**default**|*id[=socket>|< key > [,< key > ]*
2021-08-11 06:11:15 +08:00
2021-07-26 14:07:23 +08:00
SSH agent socket or keys to expose to the build.
The socket path can be left empty to use the value of `default=$SSH_AUTH_SOCK`
To later use the ssh agent, use the --mount flag in a `RUN` instruction within a `Containerfile` :
`RUN --mount=type=secret,id=id mycmd`
2020-12-11 09:56:17 +08:00
**--stdin**
2022-01-26 04:55:55 +08:00
Pass stdin into the RUN containers. Sometimes commands being RUN within a Containerfile
2020-12-11 09:56:17 +08:00
want to request information from the user. For example apt asking for a confirmation for install.
Use --stdin to be able to interact from the terminal during the build.
New CI check: xref --help vs man pages
Run 'buildah --help', recursively against all subcommands,
then cross-reference the results against docs/buildah*.md.
Report differences in subcommands and/or flags.
The majority of the changes in this PR are trivial (see
below) but a handful may be controversial and require
careful review:
* Making 'bud' the default output of 'buildah help',
with 'build-using-dockerfile' as an alias. This is
the inverse of the situation until now: buildah
would list build-using-dockerfile as the primary
name. The man page, OTOH, lists 'bud'. The source
file name is 'bud'. I suspect that most people
type 'bud'. So, for consistency, I choose to make
'bud' the default visible command.
* add --encryption-key and --encrypt-layer documentation
to buildah-commit.md, and --encrypt-layer to -push.md.
Please double-check the wording here.
* remove --notruncate from buildah-images.md. The option
does not exist (although there is a TODO comment in
the code). If it should exist, it is left to the
reader to implement. I would humbly suggest that this
is a good idea, for consistency with buildah containers.
* remove --shm-size from buildah-pull.md. The option
does not exist, and I suspect this was a copy-paste error.
* remove --security-opt from run.go. It was unimplemented
and undocumented.
* remove --userns-[gu]id-map from buildah-bud.md. These
are global options, not bud options, and are documented
well enough in buildah.bud.
Trivial (IMO) changes:
* split options in man pages, from '**--foo, -f**'
to '**--foo**, **-f**'. This conforms with the style
used in podman man pages.
* add missing one-letter aliases (usually "-q", "-a")
* add missing man page entries for some easy options
* sort out-of-order subcommand listings in man pages
Finally, do note that this is a copy-and-alter duplicate of the
original script in podman, and that is horrible. In an ideal
world I would've been able to refactor the podman version into
something usable on both repos (and then more). It turns out the
differences in man page format and in special-case handling are
too broad to let me do a clean refactor.
Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-09-21 22:51:19 +08:00
**--tag**, ** -t** *imageName*
2017-04-14 04:23:31 +08:00
Specifies the name which will be assigned to the resulting image if the build
process completes successfully.
bud: teach --platform to take a list
Add a pkg/parse.PlatformsFromOptions() which understands a "variant"
value as an optional third value in an OS/ARCH[/VARIANT] argument value,
which accepts a comma-separated list of them, and which returns a list
of platforms.
Teach "from" and "pull" about the --platform option and add integration
tests for them, warning if --platform was given multiple values.
Add a define.BuildOptions.JobSemaphore which an imagebuildah executor
will use in preference to one that it might allocate for itself.
In main(), allocate a JobSemaphore if the number of jobs is not 0 (which
we treat as "unlimited", and continue to allow executors to do).
In addManifest(), take a lock on the manifest list's image ID so that we
don't overwrite changes that another thread might be making while we're
attempting to make changes to it. In main(), create an empty list if
the list doesn't already exist before we start down this path, so that
we don't get two threads trying to create that manifest list at the same
time later on. Two processes could still try to create the same list
twice, but it's an incremental improvement.
Finally, if we've been given multiple platforms to build for, run their
builds concurrently and gather up their results.
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2021-06-22 22:52:49 +08:00
If _imageName_ does not include a registry name component, the registry name *localhost* will be prepended to the image name.
2017-04-14 04:23:31 +08:00
2023-12-17 20:00:58 +08:00
The ** --tag** option supports all transports from `containers-transports(5)` .
2024-01-08 22:58:08 +08:00
If no transport is specified, the `containers-storage` (i.e., local storage) transport is used.
2023-12-17 20:00:58 +08:00
__buildah build --tag=oci-archive:./foo.ociarchive .__
__buildah build -t quay.io/username/foo .__
2019-02-03 07:31:44 +08:00
**--target** *stageName*
2019-09-16 01:29:56 +08:00
Set the target build stage to build. When building a Containerfile with multiple build stages, --target
2019-02-03 07:31:44 +08:00
can be used to specify an intermediate build stage by name as the final stage for the resulting image.
Commands after the target stage will be skipped.
2020-11-06 09:56:22 +08:00
**--timestamp** *seconds*
2025-04-30 05:04:20 +08:00
Set the "created" timestamp for the built image to this number of seconds since
the epoch (Unix time 0, i.e., 00:00:00 UTC on 1 January 1970) (defaults to
current time).
The "created" timestamp is written into the image's configuration and manifest
when the image is committed, so running the same build two different times
will ordinarily produce images with different sha256 hashes, even if no other
changes were made to the Containerfile and build context.
When --timestamp is set, the "created" timestamp is always set to the time
specified, which should allow for identical images to be built at different
times using the same set of inputs.
When --timestamp is set, all content in layers created as part of the build,
and output written as specified to the ** --output** flag, will also bear this
same timestamp.
Conflicts with the similar ** --source-date-epoch** flag, which by default does
not affect the timestamps of layer contents.
2020-11-06 09:56:22 +08:00
2017-10-22 04:31:21 +08:00
**--tls-verify** *bool-value*
2024-07-20 02:07:25 +08:00
Require HTTPS and verification of certificates when talking to container registries (defaults to true) and retrieving content from HTTPS locations for ADD instructions. TLS verification cannot be used when talking to an insecure registry.
2017-10-22 04:31:21 +08:00
2018-07-30 23:54:15 +08:00
**--ulimit** *type* =*soft-limit*[:*hard-limit*]
2018-03-07 07:13:24 +08:00
Specifies resource limits to apply to processes launched when processing `RUN` instructions.
This option can be specified multiple times. Recognized resource types
include:
2019-11-17 00:31:41 +08:00
"core": maximum core dump size (ulimit -c)
2018-03-07 07:13:24 +08:00
"cpu": maximum CPU time (ulimit -t)
"data": maximum size of a process's data segment (ulimit -d)
"fsize": maximum size of new files (ulimit -f)
"locks": maximum number of file locks (ulimit -x)
"memlock": maximum amount of locked memory (ulimit -l)
"msgqueue": maximum amount of data in message queues (ulimit -q)
"nice": niceness adjustment (nice -n, ulimit -e)
"nofile": maximum number of open files (ulimit -n)
2018-07-30 23:54:15 +08:00
"nofile": maximum number of open files (1048576); when run by root
2018-03-07 07:13:24 +08:00
"nproc": maximum number of processes (ulimit -u)
2018-07-30 23:54:15 +08:00
"nproc": maximum number of processes (1048576); when run by root
2018-03-07 07:13:24 +08:00
"rss": maximum size of a process's (ulimit -m)
"rtprio": maximum real-time scheduling priority (ulimit -r)
"rttime": maximum amount of real-time execution between blocking syscalls
"sigpending": maximum number of pending signals (ulimit -i)
"stack": maximum stack size (ulimit -s)
2018-02-14 03:58:56 +08:00
2025-06-02 00:16:38 +08:00
**--unsetannotation** *annotation*
Unset the image annotation, causing the annotation not to be inherited from the base image.
2021-11-02 04:52:48 +08:00
**--unsetenv** *env*
Unset environment variables from the final image.
2023-09-23 01:34:15 +08:00
**--unsetlabel** *label*
Unset the image label, causing the label not to be inherited from the base image.
2018-03-13 01:53:12 +08:00
**--userns** *how*
Sets the configuration for user namespaces when handling `RUN` instructions.
2022-06-20 15:29:56 +08:00
The configured value can be "" (the empty string) , "private" or "auto" to indicate
2018-03-13 01:53:12 +08:00
that a new user namespace should be created, it can be "host" to indicate that
the user namespace in which `buildah` itself is being run should be reused, or
it can be the path to an user namespace which is already in use by another
process.
2022-06-20 15:29:56 +08:00
auto: automatically create a unique user namespace.
The --userns=auto flag, requires that the user name containers and a range of subordinate user ids that the build container is allowed to use be specified in the /etc/subuid and /etc/subgid files.
Example: `containers:2147483647:2147483648` .
Buildah allocates unique ranges of UIDs and GIDs from the containers subordinate user ids. The size of the ranges is based on the number of UIDs required in the image. The number of UIDs and GIDs can be overridden with the size option.
Valid `auto` options:
* gidmapping=CONTAINER_GID:HOST_GID:SIZE: to force a GID mapping to be present in the user namespace.
* size=SIZE: to specify an explicit size for the automatic user namespace. e.g. --userns=auto:size=8192. If size is not specified, auto will estimate a size for the user namespace.
* uidmapping=CONTAINER_UID:HOST_UID:SIZE: to force a UID mapping to be present in the user namespace.
2022-10-12 19:18:22 +08:00
**--userns-gid-map** *mapping*
Directly specifies a GID mapping which should be used to set ownership, at the
filesystem level, on the working container's contents.
Commands run when handling `RUN` instructions will default to being run in
their own user namespaces, configured using the UID and GID maps.
Entries in this map take the form of one or more colon-separated triples of a starting
in-container GID, a corresponding starting host-level GID, and the number of
consecutive IDs which the map entry represents.
This option overrides the *remap-gids* setting in the *options* section of
/etc/containers/storage.conf.
If this option is not specified, but a global --userns-gid-map setting is
supplied, settings from the global option will be used.
2022-03-24 20:03:06 +08:00
**--userns-gid-map-group** *group*
2018-03-13 01:53:12 +08:00
2022-03-24 20:03:06 +08:00
Specifies that a GID mapping which should be used to set ownership, at the
2019-11-17 00:31:41 +08:00
filesystem level, on the working container's contents, can be found in entries
2022-03-24 20:03:06 +08:00
in the `/etc/subgid` file which correspond to the specified group.
2018-03-13 01:53:12 +08:00
Commands run when handling `RUN` instructions will default to being run in
their own user namespaces, configured using the UID and GID maps.
2022-03-24 20:03:06 +08:00
If --userns-uid-map-user is specified, but --userns-gid-map-group is not
specified, `buildah` will assume that the specified user name is also a
suitable group name to use as the default setting for this option.
2018-03-13 01:53:12 +08:00
2022-03-24 20:03:06 +08:00
Users can specify the maps directly using `--userns-gid-map` described in the buildah(1) man page.
2020-09-30 22:15:21 +08:00
2021-03-23 00:07:07 +08:00
**NOTE:** When this option is specified by a rootless user, the specified mappings are relative to the rootless usernamespace in the container, rather than being relative to the host as it would be when run rootful.
2021-02-28 02:46:43 +08:00
2022-10-12 19:18:22 +08:00
**--userns-uid-map** *mapping*
Directly specifies a UID mapping which should be used to set ownership, at the
filesystem level, on the working container's contents.
Commands run when handling `RUN` instructions will default to being run in
their own user namespaces, configured using the UID and GID maps.
Entries in this map take the form of one or more colon-separated triples of a starting
in-container UID, a corresponding starting host-level UID, and the number of
consecutive IDs which the map entry represents.
This option overrides the *remap-uids* setting in the *options* section of
/etc/containers/storage.conf.
If this option is not specified, but a global --userns-uid-map setting is
supplied, settings from the global option will be used.
2022-03-24 20:03:06 +08:00
**--userns-uid-map-user** *user*
2018-03-13 01:53:12 +08:00
2022-03-24 20:03:06 +08:00
Specifies that a UID mapping which should be used to set ownership, at the
2019-11-17 00:31:41 +08:00
filesystem level, on the working container's contents, can be found in entries
2022-03-24 20:03:06 +08:00
in the `/etc/subuid` file which correspond to the specified user.
2018-03-13 01:53:12 +08:00
Commands run when handling `RUN` instructions will default to being run in
their own user namespaces, configured using the UID and GID maps.
2022-03-24 20:03:06 +08:00
If --userns-gid-map-group is specified, but --userns-uid-map-user is not
specified, `buildah` will assume that the specified group name is also a
suitable user name to use as the default setting for this option.
2018-03-13 01:53:12 +08:00
2021-03-23 00:07:07 +08:00
**NOTE:** When this option is specified by a rootless user, the specified mappings are relative to the rootless usernamespace in the container, rather than being relative to the host as it would be when run rootful.
2021-02-28 02:46:43 +08:00
2018-03-13 01:53:12 +08:00
**--uts** *how*
2022-01-26 04:55:55 +08:00
Sets the configuration for UTS namespaces when handling `RUN` instructions.
2018-03-13 01:53:12 +08:00
The configured value can be "" (the empty string) or "container" to indicate
that a new UTS namespace should be created, or it can be "host" to indicate
that the UTS namespace in which `buildah` 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.
2020-12-23 05:12:38 +08:00
**--variant**=""
Set the architecture variant of the image to be pulled.
New CI check: xref --help vs man pages
Run 'buildah --help', recursively against all subcommands,
then cross-reference the results against docs/buildah*.md.
Report differences in subcommands and/or flags.
The majority of the changes in this PR are trivial (see
below) but a handful may be controversial and require
careful review:
* Making 'bud' the default output of 'buildah help',
with 'build-using-dockerfile' as an alias. This is
the inverse of the situation until now: buildah
would list build-using-dockerfile as the primary
name. The man page, OTOH, lists 'bud'. The source
file name is 'bud'. I suspect that most people
type 'bud'. So, for consistency, I choose to make
'bud' the default visible command.
* add --encryption-key and --encrypt-layer documentation
to buildah-commit.md, and --encrypt-layer to -push.md.
Please double-check the wording here.
* remove --notruncate from buildah-images.md. The option
does not exist (although there is a TODO comment in
the code). If it should exist, it is left to the
reader to implement. I would humbly suggest that this
is a good idea, for consistency with buildah containers.
* remove --shm-size from buildah-pull.md. The option
does not exist, and I suspect this was a copy-paste error.
* remove --security-opt from run.go. It was unimplemented
and undocumented.
* remove --userns-[gu]id-map from buildah-bud.md. These
are global options, not bud options, and are documented
well enough in buildah.bud.
Trivial (IMO) changes:
* split options in man pages, from '**--foo, -f**'
to '**--foo**, **-f**'. This conforms with the style
used in podman man pages.
* add missing one-letter aliases (usually "-q", "-a")
* add missing man page entries for some easy options
* sort out-of-order subcommand listings in man pages
Finally, do note that this is a copy-and-alter duplicate of the
original script in podman, and that is horrible. In an ideal
world I would've been able to refactor the podman version into
something usable on both repos (and then more). It turns out the
differences in man page format and in special-case handling are
too broad to let me do a clean refactor.
Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-09-21 22:51:19 +08:00
**--volume**, ** -v**[=*[HOST-DIR:CONTAINER-DIR[:OPTIONS]]*]
2018-02-23 01:41:22 +08:00
2022-01-25 06:20:04 +08:00
Mount a host directory into containers when executing *RUN* instructions during
the build. The `OPTIONS` are a comma delimited list and can be:
2018-02-23 01:41:22 +08:00
* [rw|ro]
2020-11-18 22:50:53 +08:00
* [U]
2019-04-29 21:41:18 +08:00
* [z|Z|O]
2023-12-11 23:22:21 +08:00
* [`[r]shared`|`[r]slave`|`[r]private`] < sup > [[1]](#Footnote1)</ sup >
2018-02-23 01:41:22 +08:00
The `CONTAINER-DIR` must be an absolute path such as `/src/docs` . The `HOST-DIR`
2018-04-30 06:36:35 +08:00
must be an absolute path as well. Buildah bind-mounts the `HOST-DIR` to the
path you specify. For example, if you supply `/foo` as the host path,
Buildah copies the contents of `/foo` to the container filesystem on the host
and bind mounts that into the container.
2018-02-23 01:41:22 +08:00
You can specify multiple ** -v** options to mount one or more mounts to a
container.
2020-11-18 22:50:53 +08:00
`Write Protected Volume Mounts`
2018-04-30 06:36:35 +08:00
You can add the `:ro` or `:rw` suffix to a volume to mount it read-only or
2018-02-23 01:41:22 +08:00
read-write mode, respectively. By default, the volumes are mounted read-write.
See examples.
2020-11-18 22:50:53 +08:00
`Chowning Volume Mounts`
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.
The `:U` 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.
2019-04-29 21:41:18 +08:00
`Labeling Volume Mounts`
2018-02-23 01:41:22 +08:00
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
2018-04-30 06:36:35 +08:00
default, Buildah does not change the labels set by the OS.
2018-02-23 01:41:22 +08:00
To change a label in the container context, you can add either of two suffixes
2018-04-30 06:36:35 +08:00
`:z` or `:Z` to the volume mount. These suffixes tell Buildah to relabel file
objects on the shared volumes. The `z` option tells Buildah that two containers
share the volume content. As a result, Buildah labels the content with a shared
2018-02-23 01:41:22 +08:00
content label. Shared volume labels allow all containers to read/write content.
2018-04-30 06:36:35 +08:00
The `Z` option tells Buildah to label the content with a private unshared label.
2018-02-23 01:41:22 +08:00
Only the current container can use a private volume.
2019-04-29 21:41:18 +08:00
`Overlay Volume Mounts`
2020-12-22 00:19:56 +08:00
The `:O` flag tells Buildah to mount the directory from the host as a temporary storage using the Overlay file system. The `RUN` command containers are allowed to modify contents within the mountpoint and are stored in the container storage in a separate directory. In Overlay FS terms the source directory will be the lower, and the container storage directory will be the upper. Modifications to the mount point are destroyed when the `RUN` command finishes executing, similar to a tmpfs mount point.
2019-04-29 21:41:18 +08:00
2022-01-26 04:55:55 +08:00
Any subsequent execution of `RUN` commands sees the original source directory content, any changes from previous RUN commands no longer exist.
2019-04-29 21:41:18 +08:00
One use case of the `overlay` mount is sharing the package cache from the host into the container to allow speeding up builds.
Note:
2023-12-01 04:43:59 +08:00
- The `O` flag is not allowed to be specified with the `Z` or `z` flags. Content mounted into the container is labeled with the private label.
2022-01-26 08:43:32 +08:00
On SELinux systems, labels in the source directory must be readable by the container label. If not, SELinux container separation must be disabled for the container to work.
2023-12-01 04:43:59 +08:00
- Modification of the directory volume mounted into the container with an overlay mount can cause unexpected failures. It is recommended that you do not modify the directory until the container finishes running.
2019-04-29 21:41:18 +08:00
2018-02-23 01:41:22 +08:00
By default bind mounted volumes are `private` . That means any mounts done
inside container will not be visible on the host and vice versa. This behavior can
2018-04-27 00:35:16 +08:00
be changed by specifying a volume mount propagation property.
2018-02-23 01:41:22 +08:00
When the mount propagation policy is set to `shared` , 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 `slave` , one way mount propagation is enabled
and any mounts completed on the host for that volume will be visible only inside of the container.
2018-04-30 06:36:35 +08:00
To control the mount propagation property of the volume use the `:[r]shared` ,
2018-02-23 01:41:22 +08:00
`:[r]slave` or `:[r]private` propagation flag. The propagation property can
be specified only for bind mounted volumes and not for internal volumes or
2018-04-30 06:36:35 +08:00
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
2018-02-23 01:41:22 +08:00
shared volumes, the source mount point has to be shared. And for slave volumes,
2020-07-21 01:29:29 +08:00
the source mount has to be either shared or slave. < sup > [[1]](#Footnote1)< / sup >
2018-02-23 01:41:22 +08:00
Use `df <source-dir>` to determine the source mount and then use
`findmnt -o TARGET,PROPAGATION <source-mount-dir>` to determine propagation
properties of source mount, if `findmnt` utility is not available, the source mount point
can be determined by looking at the mount entry in `/proc/self/mountinfo` . Look
2020-12-22 00:19:56 +08:00
at `optional fields` and see if any propagation properties are specified.
2018-02-23 01:41:22 +08:00
`shared:X` means the mount is `shared` , `master:X` means the mount is `slave` and if
2020-07-21 01:29:29 +08:00
nothing is there that means the mount is `private` . < sup > [[1]](#Footnote1)</ sup >
2018-02-23 01:41:22 +08:00
To change propagation properties of a mount point use the `mount` command. For
example, to bind mount the source directory `/foo` do
`mount --bind /foo /foo` and `mount --make-private --make-shared /foo` . This
will convert /foo into a `shared` mount point. The propagation properties of the source
mount can be changed directly. For instance if `/` is the source mount for
`/foo` , then use `mount --make-shared /` to convert `/` into a `shared` mount.
2020-11-25 09:04:52 +08:00
## BUILD TIME VARIABLES
The ENV instruction in a Containerfile can be used to define variable values. When the image
is built, the values will persist in the container image. At times it is more convenient to
change the values in the Containerfile via a command-line option rather than changing the
values within the Containerfile itself.
The following variables can be used in conjunction with the `--build-arg` option to override the
corresponding values set in the Containerfile using the `ENV` instruction.
* HTTP_PROXY
* HTTPS_PROXY
* FTP_PROXY
* NO_PROXY
Please refer to the [Using Build Time Variables ](#using-build-time-variables ) section of the Examples.
2017-04-14 04:23:31 +08:00
## EXAMPLE
2019-09-16 01:29:56 +08:00
### Build an image using local Containerfiles
2018-05-15 20:03:58 +08:00
2021-08-25 02:03:02 +08:00
buildah build .
2017-06-07 19:48:10 +08:00
2021-08-25 02:03:02 +08:00
buildah build -f Containerfile .
2017-06-07 19:48:10 +08:00
2021-10-09 20:26:55 +08:00
cat ~/Containerfile | buildah build -f - .
2018-07-27 22:48:16 +08:00
2021-10-09 20:26:55 +08:00
buildah build -f Containerfile.simple -f Containerfile.notsosimple .
2017-06-07 19:48:10 +08:00
2021-08-25 02:03:02 +08:00
buildah build --timestamp=$(date '+%s') -t imageName .
2020-08-27 04:56:57 +08:00
2021-08-25 02:03:02 +08:00
buildah build -t imageName .
2017-06-07 19:48:10 +08:00
2021-10-09 20:26:55 +08:00
buildah build --tls-verify=true -t imageName -f Containerfile.simple .
2017-10-22 04:31:21 +08:00
2021-08-25 02:03:02 +08:00
buildah build --tls-verify=false -t imageName .
2017-04-14 04:23:31 +08:00
2021-08-25 02:03:02 +08:00
buildah build --runtime-flag log-format=json .
2018-01-31 01:08:18 +08:00
2021-08-25 02:03:02 +08:00
buildah build -f Containerfile --runtime-flag debug .
2018-01-31 01:08:18 +08:00
2021-10-09 20:26:55 +08:00
buildah build --authfile /tmp/auths/myauths.json --cert-dir ~/auth --tls-verify=true --creds=username:password -t imageName -f Containerfile.simple .
2018-01-31 08:19:30 +08:00
2021-08-25 02:03:02 +08:00
buildah build --memory 40m --cpu-period 10000 --cpu-quota 50000 --ulimit nofile=1024:1028 -t imageName .
2018-02-14 03:58:56 +08:00
2021-08-25 02:03:02 +08:00
buildah build --security-opt label=level:s0:c100,c200 --cgroup-parent /path/to/cgroup/parent -t imageName .
2018-02-14 03:58:56 +08:00
2021-08-25 02:03:02 +08:00
buildah build --arch=arm --variant v7 -t imageName .
2020-12-23 05:12:38 +08:00
2021-08-25 02:03:02 +08:00
buildah build --volume /home/test:/myvol:ro,Z -t imageName .
2018-02-23 01:41:22 +08:00
2021-08-25 02:03:02 +08:00
buildah build -v /home/test:/myvol:z,U -t imageName .
2020-11-18 22:50:53 +08:00
2021-08-25 02:03:02 +08:00
buildah build -v /var/lib/dnf:/var/lib/dnf:O -t imageName .
2019-04-29 21:41:18 +08:00
2021-08-25 02:03:02 +08:00
buildah build --layers -t imageName .
2018-06-09 00:55:46 +08:00
2021-08-25 02:03:02 +08:00
buildah build --no-cache -t imageName .
2018-06-09 00:55:46 +08:00
2021-08-25 02:03:02 +08:00
buildah build -f Containerfile --layers --force-rm -t imageName .
2018-06-14 02:09:45 +08:00
2021-08-25 02:03:02 +08:00
buildah build --no-cache --rm=false -t imageName .
2018-06-14 02:09:45 +08:00
2021-08-25 02:03:02 +08:00
buildah build --dns-search=example.com --dns=223.5.5.5 --dns-option=use-vc .
2019-04-07 00:03:58 +08:00
2022-05-14 18:58:34 +08:00
buildah build -f Containerfile.in --cpp-flag="-DDEBUG" -t imageName .
2021-05-19 21:05:47 +08:00
2022-01-19 23:43:02 +08:00
buildah build --network mynet .
2022-05-03 06:24:59 +08:00
buildah build --env LANG=en_US.UTF-8 -t imageName .
buildah build --env EDITOR -t imageName .
buildah build --unsetenv LANG -t imageName .
2022-05-03 06:37:36 +08:00
buildah build --os-version 10.0.19042.1645 -t imageName .
buildah build --os-feature win32k -t imageName .
buildah build --os-feature win32k- -t imageName .
2025-02-22 15:21:28 +08:00
buildah build --secret=id=mysecret .
buildah build --secret=id=mysecret,env=MYSECRET .
buildah build --secret=id=mysecret,src=MYSECRET,type=env .
buildah build --secret=id=mysecret,src=.mysecret,type=file .
buildah build --secret=id=mysecret,src=.mysecret .
2021-08-11 06:11:15 +08:00
### Building an multi-architecture image using the --manifest option (requires emulation software)
2020-12-30 20:16:24 +08:00
2021-08-25 02:03:02 +08:00
buildah build --arch arm --manifest myimage /tmp/mysrc
2021-07-09 23:12:01 +08:00
2021-08-25 02:03:02 +08:00
buildah build --arch amd64 --manifest myimage /tmp/mysrc
2021-07-09 23:12:01 +08:00
2021-08-25 02:03:02 +08:00
buildah build --arch s390x --manifest myimage /tmp/mysrc
2020-12-30 20:16:24 +08:00
2021-08-11 06:11:15 +08:00
buildah bud --platform linux/s390x,linux/ppc64le,linux/amd64 --manifest myimage /tmp/mysrc
2023-04-13 19:02:33 +08:00
buildah build --platform linux/arm64 --platform linux/amd64 --manifest myimage /tmp/mysrc
2021-08-11 06:11:15 +08:00
2021-09-28 05:26:01 +08:00
buildah bud --all-platforms --manifest myimage /tmp/mysrc
2022-04-29 21:39:42 +08:00
### Building an image using (--output) custom build output
buildah build -o out .
buildah build --output type=local,dest=out .
buildah build --output type=tar,dest=out.tar .
buildah build -o - . > out.tar
2018-05-15 20:03:58 +08:00
### Building an image using a URL
2019-09-16 01:29:56 +08:00
This will clone the specified GitHub repository from the URL and use it as context. The Containerfile or Dockerfile at the root of the repository is used as the context of the build. This only works if the GitHub repository is a dedicated repository.
2018-05-15 20:03:58 +08:00
2023-09-05 12:43:38 +08:00
buildah build https://github.com/containers/PodmanHello.git
2018-05-15 20:03:58 +08:00
2022-08-10 18:59:27 +08:00
Note: Github does not support using `git://` for performing `clone` operation due to recent changes in their security guidance (https://github.blog/2021-09-01-improving-git-protocol-security-github/). Use an `https://` URL if the source repository is hosted on Github.
2018-05-15 20:03:58 +08:00
### Building an image using a URL to a tarball'ed context
2022-05-03 06:40:01 +08:00
2019-09-16 01:29:56 +08:00
Buildah will fetch the tarball archive, decompress it and use its contents as the build context. The Containerfile or Dockerfile at the root of the archive and the rest of the archive will get used as the context of the build. If you pass an -f PATH/Containerfile option as well, the system will look for that file inside the contents of the tarball.
2018-05-15 20:03:58 +08:00
2021-10-09 20:26:55 +08:00
buildah build -f dev/Containerfile https://10.10.10.1/buildah/context.tar.gz
2018-05-15 20:03:58 +08:00
Note: supported compression formats are 'xz', 'bzip2', 'gzip' and 'identity' (no compression).
2020-11-25 09:04:52 +08:00
### Using Build Time Variables
2022-05-03 06:40:01 +08:00
2020-11-25 09:04:52 +08:00
#### Replace the value set for the HTTP_PROXY environment variable within the Containerfile.
2021-08-25 02:03:02 +08:00
buildah build --build-arg=HTTP_PROXY="http://127.0.0.1:8321"
2020-11-25 09:04:52 +08:00
2019-12-18 00:01:52 +08:00
## ENVIRONMENT
**BUILD\_REGISTRY\_SOURCES**
BUILD\_REGISTRY\_SOURCES, if set, is treated as a JSON object which contains
lists of registry names under the keys `insecureRegistries` ,
`blockedRegistries` , and `allowedRegistries` .
When pulling an image from a registry, if the name of the registry matches any
of the items in the `blockedRegistries` list, the image pull attempt is denied.
If there are registries in the `allowedRegistries` list, and the registry's
name is not in the list, the pull attempt is denied.
**TMPDIR**
The TMPDIR environment variable allows the user to specify where temporary files
are stored while pulling and pushing images. Defaults to '/var/tmp'.
2018-05-03 04:53:27 +08:00
## Files
2021-03-13 19:41:15 +08:00
### `.containerignore`/`.dockerignore`
2020-08-05 01:54:08 +08:00
2021-03-13 19:41:15 +08:00
If the .containerignore/.dockerignore file exists in the context directory,
2021-08-25 02:03:02 +08:00
`buildah build` reads its contents. If both exist, then .containerignore is used.
2021-03-13 19:41:15 +08:00
Use the `--ignorefile` flag to override the ignore file path location. Buildah uses the content to exclude files and directories from the context directory, when executing COPY and ADD directives in the Containerfile/Dockerfile
2020-08-05 01:54:08 +08:00
2021-03-13 19:41:15 +08:00
Users can specify a series of Unix shell globals in a
.containerignore/.dockerignore file to identify files/directories to exclude.
2020-08-05 01:54:08 +08:00
Buildah supports a special wildcard string `**` which matches any number of
2023-12-05 03:05:38 +08:00
directories (including zero). For example, `**/*.go` will exclude all files that
2020-08-05 01:54:08 +08:00
end with .go that are found in all directories.
2021-03-13 19:41:15 +08:00
Example .containerignore file:
2020-08-05 01:54:08 +08:00
```
2020-08-07 16:59:27 +08:00
# exclude this content for image
*/*.c
**/output*
src
2020-08-05 01:54:08 +08:00
```
2020-08-07 16:59:27 +08:00
`*/*.c`
2022-01-26 04:55:55 +08:00
Excludes files and directories whose names end with .c in any top level subdirectory. For example, the source file include/rootless.c.
2020-08-05 01:54:08 +08:00
2020-08-07 16:59:27 +08:00
`**/output*`
Excludes files and directories starting with `output` from any directory.
2020-08-05 01:54:08 +08:00
2020-08-07 16:59:27 +08:00
`src`
Excludes files named src and the directory src as well as any content in it.
2020-08-05 01:54:08 +08:00
Lines starting with ! (exclamation mark) can be used to make exceptions to
2021-03-13 19:41:15 +08:00
exclusions. The following is an example .containerignore/.dockerignore file that uses this
2020-08-05 01:54:08 +08:00
mechanism:
```
2020-08-07 16:59:27 +08:00
*.doc
!Help.doc
2020-08-05 01:54:08 +08:00
```
2020-08-07 16:59:27 +08:00
Exclude all doc files except Help.doc from the image.
2020-08-05 01:54:08 +08:00
2021-10-09 20:26:55 +08:00
This functionality is compatible with the handling of .containerignore files described here:
2020-08-05 01:54:08 +08:00
2024-03-14 17:58:09 +08:00
https://github.com/containers/common/blob/main/docs/containerignore.5.md
2020-08-05 01:54:08 +08:00
2018-05-03 04:53:27 +08:00
**registries.conf** (`/etc/containers/registries.conf`)
2018-06-11 21:57:45 +08:00
registries.conf is the configuration file which specifies which container registries should be consulted when completing image names which do not include a registry or domain portion.
2018-05-03 04:53:27 +08:00
2019-02-27 23:29:09 +08:00
**policy.json** (`/etc/containers/policy.json`)
Signature policy file. This defines the trust policy for container images. Controls which container registries can be used for image, and whether or not the tool should trust the images.
2017-04-14 04:23:31 +08:00
## SEE ALSO
2024-01-26 04:50:33 +08:00
buildah(1), cpp(1), buildah-login(1), docker-login(1), namespaces(7), pid\_namespaces(7), containers-policy.json(5), containers-registries.conf(5), user\_namespaces(7), crun(1), runc(8), containers.conf(5), oci-hooks(5), containers-transports(5), containers-auth.json(5)
2020-07-21 01:29:29 +08:00
## FOOTNOTES
< a name = "Footnote1" > 1</ a > : The Buildah project is committed to inclusivity, a core value of open source. The `master` and `slave` 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.