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
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*
2022-01-26 04:55:55 +08:00
Path of the authentication file. Default is ${XDG_\RUNTIME\_DIR}/containers/auth.json. If XDG_RUNTIME_DIR is not set, the default is /run/containers/$UID/auth.json. 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.
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-07-18 13:47:55 +08:00
Repository to utilize as a potential cache source. When specified, Buildah will try to look for
cache images in the specified repository and will attempt to pull cache images instead of actually
executing the build steps locally. Buildah will only attempt to pull previously cached images if they
are considered as valid cache hits.
Use the `--cache-to` option to populate a remote repository with cache content.
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.
**--cache-to**
Set this flag to specify a remote repository that will be used to store cache images. Buildah will attempt to
push newly built cache image to the remote repository.
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
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.
The CAP\_AUDIT\_WRITE, CAP\_CHOWN, CAP\_DAC\_OVERRIDE, CAP\_FOWNER,
CAP\_FSETID, CAP\_KILL, CAP\_MKNOD, CAP\_NET\_BIND\_SERVICE, CAP\_SETFCAP,
CAP\_SETGID, CAP\_SETPCAP, CAP\_SETUID, and CAP\_SYS\_CHROOT capabilities are
granted by default; this option can be used to remove them.
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*
2018-05-02 03:37:13 +08:00
Use certificates at *path* (\*.crt, \*.cert, \*.key) to connect to the registry.
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**=""
Path to cgroups under which the cgroup for the container 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.
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.
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.
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.
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*
2020-11-06 09:56:22 +08:00
Add a host device to the container. Optional *permissions* parameter
can be used to specify device permissions, it is combination of
**r** for read, **w** for write, and **m** for **mknod** (2).
Example: ** --device=/dev/sdc:/dev/xvdc:rwm**.
Note: if _host_device_ is a symbolic link then it will be resolved first.
The container will only store the major and minor numbers of the host device.
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.
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
2017-04-14 04:23:31 +08:00
first specified file.
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-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*
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. Buildah currently support both the 1.0.0 and 0.1.0 hook schemas, although the 0.1.0 schema is deprecated.
This option may be set multiple times; paths from later options have higher precedence.
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*
Adds default identity label `io.buildah.version` if set. (default true).
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
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
2020-11-20 22:52:51 +08:00
container engines, like Podman, to run the container with just these
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
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.
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
2022-03-08 04:44:14 +08:00
**--no-hosts**
Do not create _/etc/hosts_ for the container.
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**=""
Output destination (format: type=local,dest=path)
The --output (or -o) option extends the default behavior of building a container image by allowing users to export the contents of the image as files on the local filesystem, which can be useful for generating local binaries, code generation, etc.
The value for --output is a comma-separated sequence of key=value pairs, defining the output type and options.
Supported _keys_ are:
- **dest**: Destination path for exported output. Valid value is absolute or relative path, `-` means the standard output.
- **type**: Defines the type of output to be used. Valid values is documented below.
Valid _type_ values are:
- **local**: write the resulting build files to a directory on the client-side.
- **tar**: write the resulting files as a single tarball (.tar).
If no type is specified, the value defaults to **local** .
Alternatively, instead of a comma-separated sequence, the value of ** --output** can be just a destination (in the `**dest** format) (e.g. ` --output some-path`, `--output -` ) where `--output some-path` is treated as if **type=local** and `--output -` is treated as if **type=tar** .
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
2021-10-09 22:43:09 +08:00
architecture of the host (for example `linux/arm` ).
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` .
While `buildah bud` is happy to use base images and build images for any
platform that exists, `RUN` instructions will not be able to succeed without
the help of emulation provided by packages like `qemu-user-static` .
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**
2022-01-23 06:17:38 +08:00
When the flag is enabled or set explicitly to `true` (with *--pull=true* ), attempt to pull the latest image from the registries
2019-03-05 04:01:44 +08:00
listed in registries.conf if a local image does not exist or the image is newer
than the one in storage. Raise an error if the image is not in any listed
registry and is not present locally.
If the flag is disabled (with *--pull=false* ), do not pull the image from the
2022-01-23 06:17:38 +08:00
registry, use only the local version. Raise an error if the image is not
present locally.
2019-03-05 04:01:44 +08:00
2022-01-23 06:17:38 +08:00
If the pull flag is set to `always` (with *--pull=always* ),
pull the image from the first registry it is found in as listed in registries.conf.
2019-03-05 04:01:44 +08:00
Raise an error if not found in the registries, even if the image is present locally.
2017-04-14 04:23:31 +08:00
2022-01-23 06:17:38 +08:00
If the pull flag is set to `never` (with *--pull=never* ),
Fix --pull=true||false and add --pull-never to bud and from (retry)
(Replaces #1873 as it had lint issues that were timing out tests that I couldn't
track down easily)
Prior to this fix, if someone did `buildah bud --pull=false .` and the image in
the Containerfile's FROM statement was not local, the build would fail. The same
build on Docker will succeed. In Docker, when `--pull` is set to false, it only
pulls the image from the registry if there was not one locally. Buildah would never
pull the image and if the image was not locally available, it would throw an error.
In certain Kubernetes environments, this was especially troublesome.
To retain the old `--pull=false` functionality, I've created a new `--pull-never`
option that fails if an image is not locally available just like the old
`--pull=false` option used to do.
In addition, if there was a newer version of the image on the repository than
the one locally, the `--pull=true` option would not pull the image as it should
have, this corrects that.
Changes both the from and bud commands.
Addresses: #1675
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
Closes: #1959
Approved by: rhatdan
2019-10-31 22:15:56 +08:00
Do not pull the image from the registry, use only the local version. Raise an error
if the image is not present locally.
2022-01-23 06:17:38 +08:00
Defaults to *true* .
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` .
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*
2018-01-31 01:08:18 +08:00
Adds global flags for the container rutime. 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
2021-04-17 06:21:31 +08:00
**--secret**=**id=id,src=path**
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.
The secret will be mounted in the container at the default location of `/run/secrets/id` .
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`
2018-02-14 03:58:56 +08:00
**--security-opt**=[]
Security Options
2020-11-06 09:56:22 +08:00
"apparmor=unconfined" : Turn off apparmor confinement for the container
"apparmor=your-profile" : Set the apparmor confinement profile for the container
2018-02-14 03:58:56 +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
"no-new-privileges" : Not supported
"seccomp=unconfined" : Turn off seccomp confinement for the container
"seccomp=profile.json : White listed syscalls seccomp Json file to be used as a seccomp filter
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` ).
2018-04-27 00:35:16 +08:00
**--squash**
2020-11-06 09:56:22 +08:00
Squash all of the image's new layers into a single new layer; any preexisting layers
are not squashed.
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
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*
Set the create timestamp to seconds since epoch to allow for deterministic builds (defaults to current time).
By default, the created timestamp is changed and written into the image manifest with every commit,
causing the image's sha256 hash to be different even if the sources are exactly the same otherwise.
When --timestamp is set, the created timestamp is always set to the time specified and therefore not changed, allowing the image's sha256 to remain the same. All files committed to the layers of the image will be created with the timestamp.
2017-10-22 04:31:21 +08:00
**--tls-verify** *bool-value*
2020-12-30 20:16:24 +08:00
Require HTTPS and verification of certificates when talking to container registries (defaults to true). 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
2021-11-02 04:52:48 +08:00
**--unsetenv** *env*
Unset environment variables from the final 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-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-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
2022-03-24 20:03:06 +08:00
Users can specify the maps directly using `--userns-uid-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
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:
< sup > [[1]](#Footnote1)< / sup >
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]
2018-02-23 01:41:22 +08:00
* [`[r]shared`|`[r]slave`|`[r]private`]
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:
- 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.
2019-04-29 21:41:18 +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.
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 .
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
buildah bud --platform linux/arm64 --platform linux/amd64 --manifest myimage /tmp/mysrc
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
2022-08-10 18:59:27 +08:00
buildah build https://github.com/scollier/purpletest
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
directories (including zero). For example, ** /*.go will exclude all files that
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
2021-10-09 20:26:55 +08:00
https://github.com/containers/buildah/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
2021-05-19 21:05:47 +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)
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.