Skip to content

Commit b2bbb33

Browse files
authored
Merge pull request #2835 from dvdksn/bake-v019-entitlements
docs: bake v0.19 entitlements
2 parents 3e0682f + 012df71 commit b2bbb33

File tree

2 files changed

+103
-1
lines changed

2 files changed

+103
-1
lines changed

docs/bake-reference.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,10 @@ The following table shows the complete list of attributes that you can assign to
221221
| [`attest`](#targetattest) | List | Build attestations |
222222
| [`cache-from`](#targetcache-from) | List | External cache sources |
223223
| [`cache-to`](#targetcache-to) | List | External cache destinations |
224+
| [`call`](#targetcall) | String | Specify the frontend method to call for the target. |
224225
| [`context`](#targetcontext) | String | Set of files located in the specified path or URL |
225226
| [`contexts`](#targetcontexts) | Map | Additional build contexts |
227+
| [`description`](#targetdescription) | String | Description of a target |
226228
| [`dockerfile-inline`](#targetdockerfile-inline) | String | Inline Dockerfile string |
227229
| [`dockerfile`](#targetdockerfile) | String | Dockerfile location |
228230
| [`inherits`](#targetinherits) | List | Inherit attributes from other targets |
@@ -371,6 +373,13 @@ target "app" {
371373
}
372374
```
373375

376+
Supported values are:
377+
378+
- `build` builds the target (default)
379+
- `check`: evaluates [build checks](https://docs.docker.com/build/checks/) for the target
380+
- `outline`: displays the target's build arguments and their default values if available
381+
- `targets`: lists all Bake targets in the loaded definition, along with its [description](#targetdescription).
382+
374383
For more information about frontend methods, refer to the CLI reference for
375384
[`docker buildx build --call`](https://docs.docker.com/reference/cli/docker/buildx/build/#call).
376385

@@ -481,6 +490,25 @@ FROM baseapp
481490
RUN echo "Hello world"
482491
```
483492

493+
### `target.description`
494+
495+
Defines a human-readable description for the target, clarifying its purpose or
496+
functionality.
497+
498+
```hcl
499+
target "lint" {
500+
description = "Runs golangci-lint to detect style errors"
501+
args = {
502+
GOLANGCI_LINT_VERSION = null
503+
}
504+
dockerfile = "lint.Dockerfile"
505+
}
506+
```
507+
508+
This attribute is useful when combined with the `docker buildx bake --list=targets`
509+
option, providing a more informative output when listing the available build
510+
targets in a Bake file.
511+
484512
### `target.dockerfile-inline`
485513

486514
Uses the string value as an inline Dockerfile for the build target.

docs/reference/buildx_bake.md

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Build from a file
1515

1616
| Name | Type | Default | Description |
1717
|:------------------------------------|:--------------|:--------|:-------------------------------------------------------------------------------------------------------------|
18-
| `--allow` | `stringArray` | | Allow build to access specified resources |
18+
| [`--allow`](#allow) | `stringArray` | | Allow build to access specified resources |
1919
| [`--builder`](#builder) | `string` | | Override the configured builder instance |
2020
| [`--call`](#call) | `string` | `build` | Set method for evaluating build (`check`, `outline`, `targets`) |
2121
| [`--check`](#check) | `bool` | | Shorthand for `--call=check` |
@@ -51,6 +51,80 @@ guide for introduction to writing bake files.
5151
5252
## Examples
5353

54+
### <a name="allow"></a> Allow extra privileged entitlement (--allow)
55+
56+
```text
57+
--allow=ENTITLEMENT[=VALUE]
58+
```
59+
60+
Entitlements are designed to provide controlled access to privileged
61+
operations. By default, Buildx and BuildKit operates with restricted
62+
permissions to protect users and their systems from unintended side effects or
63+
security risks. The `--allow` flag explicitly grants access to additional
64+
entitlements, making it clear when a build or bake operation requires elevated
65+
privileges.
66+
67+
In addition to BuildKit's `network.host` and `security.insecure` entitlements
68+
(see [`docker buildx build --allow`](https://docs.docker.com/reference/cli/docker/buildx/build/#allow),
69+
Bake supports file system entitlements that grant granular control over file
70+
system access. These are particularly useful when working with builds that need
71+
access to files outside the default working directory.
72+
73+
Bake supports the following filesystem entitlements:
74+
75+
- `--allow fs=<path|*>` - Grant read and write access to files outside of the
76+
working directory.
77+
- `--allow fs.read=<path|*>` - Grant read access to files outside of the
78+
working directory.
79+
- `--allow fs.write=<path|*>` - Grant write access to files outside of the
80+
working directory.
81+
82+
The `fs` entitlements take a path value (relative or absolute) to a directory
83+
on the filesystem. Alternatively, you can pass a wildcard (`*`) to allow Bake
84+
to access the entire filesystem.
85+
86+
### Example: fs.read
87+
88+
Given the following Bake configuration, Bake would need to access the parent
89+
directory, relative to the Bake file.
90+
91+
```hcl
92+
target "app" {
93+
context = "../src"
94+
}
95+
```
96+
97+
Assuming `docker buildx bake app` is executed in the same directory as the
98+
`docker-bake.hcl` file, you would need to explicitly allow Bake to read from
99+
the `../src` directory. In this case, the following invocations all work:
100+
101+
```console
102+
$ docker buildx bake --allow fs.read=* app
103+
$ docker buildx bake --allow fs.read=../src app
104+
$ docker buildx bake --allow fs=* app
105+
```
106+
107+
### Example: fs.write
108+
109+
The following `docker-bake.hcl` file requires write access to the `/tmp`
110+
directory.
111+
112+
```hcl
113+
target "app" {
114+
output = "/tmp"
115+
}
116+
```
117+
118+
Assuming `docker buildx bake app` is executed outside of the `/tmp` directory,
119+
you would need to allow the `fs.write` entitlement, either by specifying the
120+
path or using a wildcard:
121+
122+
```console
123+
$ docker buildx bake --allow fs=/tmp app
124+
$ docker buildx bake --allow fs.write=/tmp app
125+
$ docker buildx bake --allow fs.write=* app
126+
```
127+
54128
### <a name="builder"></a> Override the configured builder instance (--builder)
55129

56130
Same as [`buildx --builder`](buildx.md#builder).

0 commit comments

Comments
 (0)