Commit Graph

77 Commits

Author SHA1 Message Date
Nalin Dahyabhai a7098c776a imagebuildah: make traditional volume handling not the default
Make the traditional handling of volumes (where they're "frozen" and can
only be modified by ADD or COPY, which requires that we cache their
contents and save/restore them before/after RUN instructions) an option
that is not enabled by default.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-07-15 09:38:28 -04:00
Daniel J Walsh 5afd52fd9d
Clarify definition of --pull options
buildah from and buildah build will now default to --pull=missing
as opposed to --pull=always, which they did before. This better
matches to the defaults in docker and podman.

No longer document --pull=true|false

Fixes: https://github.com/containers/buildah/issues/5406

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2024-06-10 15:58:37 -04:00
Nalin Dahyabhai f812c89496 Man page updates
Describe --device in `buildah from` and `buildah run`, where it's new.
Update the description of --device in `buildah build` to note that the
device nodes are only there while RUN instructions are being run, and
not to imply that they end up in the finished image.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-03-29 16:57:11 -04:00
Philippe Vlérick e635558d2a fix links to containerignore doc
Signed-off-by: Philippe Vlérick <pvlerick@gmail.com>
2024-03-14 11:07:47 +01:00
James Fraser a20d5b2a55
docs: correct default authfile path
Signed-off-by: James Fraser <wulfgar.pro@gmail.com>
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2024-02-05 12:53:24 -05:00
krumelmonster 13fd5bd2cc docs: move footnotes to where they're applicable
Followthrough on #5221, with thanks to @krumelmonster:

   move footnotes on divisive language to exactly where
   divisive language is used

Signed-off-by: Ed Santiago <santiago@redhat.com>
2024-01-31 06:33:42 -07:00
Daniel J Walsh 34dff20dae
Run codespell on code
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2024-01-28 07:25:10 -05:00
Nalin Dahyabhai cf69e8a187 build,commit: add --sbom to scan and produce SBOMs when committing
Add a --sbom flag to `buildah build` and `buildah commit` which will
scan the rootfs and specified context directories to build SPDX or
CycloneDX SBOMs and lists of package URLs.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-01-19 13:55:57 -05:00
Nalin Dahyabhai de7c1e1f73 docs: fix a couple of typos
And don't refer to a filename in an example as a directory in
accompanying text.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-01-15 09:51:19 -05:00
Daniel J Walsh 59ea8af1b3
Document use of containers-transports values in buildah
Fixes: https://github.com/containers/buildah/issues/4740

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-12-20 06:26:15 -05:00
Ed Santiago 7dfdcf33b2 [CI:DOCS] man pages: underscores, too-wide lines
- remove unnecessary backslashes on underscores

 - trim leading spaces on some notes, making them <4.
   Too many leading spaces means to format as code.

Fixes: #4986

Signed-off-by: Ed Santiago <santiago@redhat.com>
2023-11-30 13:43:59 -07:00
Daniel J Walsh 48a9c43718
Add --no-hostname option to buildah containers
Fixes: https://github.com/containers/buildah/issues/5093

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-10-24 19:43:56 -04:00
Aditya R 8b63fa37bf
build,config: add support for --unsetlabel
Just like `--unsetenv` following flag allows to unset image label.

Signed-off-by: Aditya R <arajan@redhat.com>
2023-09-27 10:27:54 +05:30
Nalin Dahyabhai 4f3abf9367 Add some docs for `build --cw`, `commit --cw`, and `mkcw`
Add docs for the new --cw option recognized by both `commit` and
`build`, and the new `mkcw` command.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2023-09-07 14:05:10 -04:00
Aditya R 3fc5274d36
docs: use valid github repo
[CI:DOCS]
[NO NEW TESTS NEEDED]
Closes: https://github.com/containers/buildah/issues/4814

Signed-off-by: Aditya R <arajan@redhat.com>
2023-09-05 10:13:42 +05:30
Aditya R cc9f15f09f
docs: add reference to oci-hooks
Closes: https://github.com/containers/buildah/issues/4987

Signed-off-by: Aditya R <arajan@redhat.com>
2023-08-28 13:26:09 +05:30
Aditya R f888b3d84b
buildah: add --layer-label for setting labels on layers
`--layer-label` allows users to set labels on intermediate labels agnostic
of the labels set on actual image. Since there are use-cases where users
want to perform operation on intermediate images only on the basis of
certain labels.

Closes: https://github.com/containers/buildah/issues/4933

Signed-off-by: Aditya R <arajan@redhat.com>
2023-08-03 12:09:12 +05:30
Paul Holzinger 74b885b9e2
buildah: add pasta(1) support
Like podman allow buildah and therefore podman build to use the network
mode pasta. The pasta integration is very simple and we do not even
need a teardown handler for that as pasta will exit on its own when the
netns path is removed.

However right now this is broken, pasta will fail to open
/proc/$pid/ns/net. I send a patch[1] to fix this upstream in pasta.
I assume this will land quickly so I like to get this in now just so we
have this included in podman v4.6. Thus the test is skipped for now.

[1] https://archives.passt.top/passt-dev/20230623082531.25947-2-pholzing@redhat.com/

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-06-23 13:58:34 +02:00
Paul Holzinger 11ba328e2b
use slirp4netns package from c/common
This uses the same code as podman for slirp4netns, this means
- ipv6 is enabled by default
- slirp4netns options are read from contianers.conf
- slirp4netns options can now be set on the cli. This required some
small rework on where we parse the network string.

Lastly I updated the --network docs, to document the new slirp4netns
mode. That included fixing up buildah-from and buildah-run pages which
were incomplete in that regard. Now we show the same for all options.

Fixes #3968

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-06-23 13:57:30 +02:00
rijenkii 7e327cf183 Add a warning to `--secret` docs
[NO NEW TESTS NEEDED]

Signed-off-by: rijenkii <me@rijenkii.tk>
2023-05-30 22:12:28 +07:00
Aditya R b37c4ee438
build: --platform must accept only arch
Make error message for `--platform` more clear and use
`platforms.Parse(` so `--platform` can automatically detect `OS` if not
specified.

Closes: https://github.com/containers/podman/issues/18194
Closes: https://github.com/containers/buildah/issues/4756

Signed-off-by: Aditya R <arajan@redhat.com>
2023-04-27 13:43:20 +05:30
Daniel J Walsh 43440ec6e4
Clarify the need for qemu-user-static package
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-04-13 07:11:14 -04:00
Daniel J Walsh 9463954942
Update docs/buildah-build.1.md
Co-authored-by: Nalin Dahyabhai <nalin@redhat.com>
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-03-28 17:48:33 -04:00
Jack Wearden aad1e994a0 code review
Signed-off-by: Jack Wearden <jack@jackwearden.co.uk>
2023-03-26 17:21:47 +01:00
Jack Wearden 3afa5ca74d build: accept arguments from file with --build-arg-file
Allows codifying build arguments into a structured file, perhaps one
named arguments.Containerargs

The build arg file also accepts comments starting #, so automated
tooling or CI/CD workflows can monitor arguments like versions to
ensure they are up-to-date.

Signed-off-by: Jack Wearden <jack@jackwearden.co.uk>
2023-03-25 11:04:23 +00:00
Aditya R c1b82d195a
build: document behaviour of buildah's distributed cache
Buildah's `--cache-to` and `--cache-from` is different from
docker/buildkit so lets document that and mention how is it different.

Closes: https://github.com/containers/buildah/issues/4612

Signed-off-by: Aditya R <arajan@redhat.com>
2023-03-07 20:38:29 +05:30
Daniel J Walsh 8125e45a58
Fix documentation on which Capabilities are allowed by default
Buildah uses the default list of capabilities as specified in
containers.conf. The man pages should reflect this.

Fixes: https://github.com/containers/buildah/issues/4576

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-02-16 07:09:58 +02:00
Aditya R dbf1d43b34
docs: specify order preference for FROM
When multiple files are specified buildah considers `FROM` instruction
from the last file specified and so does `buildkit` and `docker` so lets
specify that in docs.

[NO NEW TESTS NEEDED]
[NO TESTS NEEDED]

Closes: https://github.com/containers/buildah/issues/4544

Signed-off-by: Aditya R <arajan@redhat.com>
2023-01-30 17:21:42 +05:30
Nalin Dahyabhai 67ab55bbb7 bud: Consolidate multiple synthetic LABEL instructions
We handle --label command line arguments by appending LABEL instructions
to the Dockerfile contents before we parse it.  Previously, we were
appending a separate line for each label-value pair.  Consolidate them
for the sake of tools that arbitrarily limit the length of histories
that they're willing to accept in images (boo!).

Add a similar implementation for --env command line arguments.
Previously, we'd set them in the initial configuration for each stage
and also set them at commit-time, and that potentially overrode any
values that were explicitly in the stage itself, and which would have
affected RUN instructions.  Remove the set-at-commit-time logic so that
the history reflects what ends up in the image.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2023-01-09 16:45:10 -05:00
Daniel Celentano 938c035566 fixed squash documentation
Signed-off-by: Daniel Celentano <dacelent@redhat.com>
2023-01-06 11:26:20 -03:00
Daniel J Walsh 60be7f2509
Add support for --group-add to buildah from
Allow containers running under buildah to use
--group-add keep-groups, so that they can inherit
access to the users groups.

Also allow users to add supplimental groups to the container.

Fixes: https://github.com/containers/buildah/issues/4476

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-12-22 11:53:00 -05:00
Daniel J Walsh e33bb86787
Add documentation for buildah build --pull=missing
Fixes: https://github.com/containers/buildah/issues/3921

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-12-20 15:43:57 -05:00
Aditya R ffed850367
remote-cache: support multiple sources and destinations
Buildah must support multiple sources for remote cache when using
`--cache-to` and `--cache-from` so users can distribute and collect
cache from various sources.

We also need for compat with buildkit api which in past broke `podman`
compat build API see: https://github.com/containers/podman/pull/16380

More discussion here: https://github.com/containers/podman/pull/16380

Signed-off-by: Aditya R <arajan@redhat.com>
2022-12-05 12:10:41 +05:30
Daniel J Walsh d4c661a774
Add no-new-privileges flag
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-11-04 11:43:29 -04:00
Daniel J Walsh dc81652ffa
Fix man pages to match latest cobra settings
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-10-12 07:23:00 -04:00
Daniel J Walsh f0bee4ee3d
Merge pull request #4250 from rhatdan/dns
Prevent use of --dns* options with --net=none
2022-09-19 13:47:00 -04:00
Aditya R 3c092e5edd
build: support --skip-unused-stages for multi-stage builds
In multi-stage builds buildah will skip stages which are unused (i.e
stages which don't contribute anything to target stage directly or
indirectly) however in certain cases users need to process these unused
stages hence add support for `--skip-unused-stages` which allows users
to control this behaviour.

Ref: https://github.com/GoogleContainerTools/kaniko#flag---skip-unused-stages

Closes: https://github.com/containers/buildah/issues/4243

Signed-off-by: Aditya R <arajan@redhat.com>
2022-09-17 12:51:15 +05:30
Daniel J Walsh 87d4ae8864
Prevent use of --dns* options with --net=none
This is blocked in Podman for run and create but not
for build, we should block it also for build.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-09-15 15:10:58 -04:00
Aditya R fd14bfe545
buildah: make --cache-ttl=0s equivalent to --no-cache
If user explicitly specified `--cache-ttl=0s
it would effectively mean that user is asking
to use no cache at all. In such use cases
buildah can skip looking for cache entierly
by setting `--no-cache=true` internally.

Closes: https://github.com/containers/buildah/issues/4244

Signed-off-by: Aditya R <arajan@redhat.com>
2022-09-15 15:55:07 +05:30
Aditya R f46ef3b2d7
buildah: support for --retry and --retry-delay for push/pull failures
Allows users to configure `--retry` attempts and `--retry-delay`
duration using two additional flags for commands

* buildah build
* buildah pull
* buildah push
* buildah from
* buildah add
* buildah copy

Closes: https://github.com/containers/buildah/issues/4018

Not sure how we can test retry attempts in CI, but added a test in
tests/bud.bats which verfies we parse and added flag in other options
for sanity parsing checking.

Signed-off-by: Aditya R <arajan@redhat.com>
2022-08-23 12:31:01 +05:30
Aditya R 17e6fe01c2 docs: specify git protocol is not supported for github hosted repo
Build from URL does not supports `git://` is source is hosted on Github.
Reason: https://github.blog/2021-09-01-improving-git-protocol-security-github/

[CI:DOCS]
[NO NEW TESTS NEEDED]
[NO TESTS NEEDED]

Closes: https://github.com/containers/buildah/issues/4103

Signed-off-by: Aditya R <arajan@redhat.com>
2022-08-11 13:30:54 +05:30
Aditya R b7f51ea3d7
build: support filtering cache by duration using --cache-ttl
`build` or `bud` now supports a new flag `--cache-ttl` which accepts
duration and allows end users to ignore cache images which are not under
the specified duration.

Following flag is useful for setups/platforms which heavily relies on
`--layer` and buildah caching but want recompute certain `RUN` steps
after specified duration to make sure specific `RUN` steps are always
updated. Example `RUN dnf update` or `RUN dnf install`

Closes: https://github.com/containers/buildah/issues/4160
Somewhat similar to kaniko's: https://github.com/GoogleContainerTools/kaniko#--cache-ttl-duration

Signed-off-by: Aditya R <arajan@redhat.com>
2022-08-05 11:50:15 +05:30
Aditya R b218fdf322
build: support building from commit when using git repo as build context
When using URL to a git repo as build context allow specifying `commit`
to make sure specific `commit` is used as the build context.

Examples

```console
buildah build -t test myrepo.git#abcef123
buildah build -t test myrepo.git#abcef123
buildah build -t test myrepo.git#abcef123:somesubdir
```
Closes: https://github.com/containers/buildah/issues/4148

Signed-off-by: Aditya R <arajan@redhat.com>
2022-08-03 18:50:44 +05:30
Aditya R 6f660bde17
build,cache: support pulling/pushing cache layers to/from remote sources
Following commit

* Initiates `cacheKey` or `layerKey` for intermediate images generated
  for layers.
* Allows end users to upload cached layers with `cacheKey` to remote
  sources using `--cache-to`. `--cache-to` is a optional flag to be used
with `buildah build` which publishes cached layers to remote sources.
* Allows end users to use cached layers from `remote` sources with
  `--cache-from`. `--cache-from` is a optional flag to be used with
`buildah build` and it pulls cached layers from remote sources in a step
by step manner only if is a valid cache hit.

Example
* Populate cache source or use cached layers if already present
```bash
buildah build -t test --layers --cache-to registry/myrepo/cache --cache-from registry/myrepo/cache .
```

Future:
* `cacheKey` or `layerKey` model is only being used when working with
  remote sources however local cache lookup can be also optimized if its
is altered to use `cacheKey` model instead of iterating through all the
images in local storage. As discussed here

References:
* Feature is quite similar to `kaniko`'s `--cache-repo`: https://github.com/GoogleContainerTools/kaniko#--cache-repo

Closes: issues#620

Signed-off-by: Aditya R <arajan@redhat.com>
2022-07-26 01:49:13 +05:30
Aditya R 5686018e79
build: support OCI hooks for ephemeral build containers
Following PR adds support for OCI hooks attached to each of ephemeral
build contains which are created by `RUN` step invoked during `buildah
build` command.

Following PR also adds `--hooks-dir` flag to `buildah build` option
which allows end-users to specify one or more configuration directories
for OCI-hooks.

Note: Following PR migrates `pkg/hooks` from `podman` to `buildah` so
buildah could implement this feature and once merged `podman` can start
using `buildah/pkg/hooks`.

For usage see man-page and example test-case.

See: https://github.com/opencontainers/runtime-spec/blob/main/config.md#posix-platform-hooks

Closes: https://github.com/containers/buildah/issues/4068

Signed-off-by: Aditya R <arajan@redhat.com>
2022-06-28 11:21:28 +05:30
Aditya R 20c5c5c6d8
build, userns: add support for --userns=auto
Buildah now supports `--userns=auto` which can automatically pick an empty range and create an user namespace for the container.

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.

Signed-off-by: Aditya R <arajan@redhat.com>
2022-06-20 13:08:02 +05:30
Aditya R 495add9369
build, multiarch: support splitting build logs for --platform
Support splitting build logs for multi-arch builds ( `--platform` ) by
using `--logfile` and `--logsplit` which splits generated log file in the
convention `${file}_${platform_os}_${platform_arch}`.

Closes: https://github.com/containers/buildah/issues/3960

Signed-off-by: Aditya R <arajan@redhat.com>
2022-06-06 20:23:23 +05:30
Aditya R c61ecc6964
build, commit: allow disabling image history with --omit-history
As per `OCI` `image-spec` setting history is optional so buildah must
support these use-cases via `--omit-history=true` some of the use-cases
are discussed below.

* There are use-cases when image-spec contributes to the image size by
  adding build history to image-spec in certain use-cases this image
history is not required by the end-users but there is no way to remove
it. See: https://github.com/containers/buildah/issues/3513

* Certain build tools don't honor setting build history in image spec
  however buildah does not allow processing images without build history
since setting build history is still optional as per `OCI` image-spec
( https://github.com/opencontainers/image-spec/blob/main/config.md#properties)
so buildah must support such use-cases.

Closes: https://github.com/containers/buildah/issues/4025
Closes: https://github.com/containers/buildah/issues/3513

Signed-off-by: Aditya R <arajan@redhat.com>
2022-06-03 00:40:48 +05:30
Aditya R c2adbade7c
buildkit: supports additionalBuildContext in builds via --build-context
As builds got more complicated, the ability to only access files from one location became quite limiting. With `multi-stage` builds where you can `copy` files from other parts of the Containerfile by adding the `--from` flag and pointing it to the name of another Containerfile stage or a remote image.

The new named build context feature is an extension of this pattern. You can now define additional build contexts when running the build command, give them a name, and then access them inside a Dockerfile the same way you previously did with build stages.

Additional build contexts can be defined with a new `--build-context [name]=[value]` flag. The key component defines the name for your build context and the value can be:

```console

    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 – Define with a docker-image:// prefix, e.g. --build-context alpine=docker-image://alpine:3.15, ( also supports docker://, container-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 Dockerfile
* Remote image `[name]` in a container registry

Added Features

* Pinning images for `FROM` and `COPY`
* Specifying multiple buildcontexts from different projects
  and using them with `--from` in `ADD` and `COPY` directive
* Override a Remote Dependency with a Local One.
* Using additional context from external `Tar`

Signed-off-by: Aditya R <arajan@redhat.com>
2022-05-17 23:43:51 +05:30
OpenShift Merge Robot 6fc2b10ddf
Merge pull request #3994 from rhatdan/cpp
Add --cpp-flag flag to buildah build
2022-05-16 19:23:44 +02:00