Skip to content

Commit 642c778

Browse files
committed
docs: add docs for bake --allow
Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
1 parent 7b7affb commit 642c778

File tree

1 file changed

+61
-1
lines changed

1 file changed

+61
-1
lines changed

docs/reference/buildx_bake.md

Lines changed: 61 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` |
@@ -50,6 +50,66 @@ guide for introduction to writing bake files.
5050
5151
## Examples
5252

53+
### <a name="allow"></a> Allow extra privileged entitelement (--allow)
54+
55+
```text
56+
--allow=ENTITLEMENT[=VALUE]
57+
```
58+
59+
In addition to BuildKit's `network.host` and `security.insecure` entitlements
60+
(see [`docker buildx build --allow`](https://docs.docker.com/reference/cli/docker/buildx/build/#allow),
61+
Bake also supports the following entitlements:
62+
63+
- `fs.read=<path|*>` - Grant read access to files outside of the working
64+
directory.
65+
- `fs.write=<path|*>` - Grant write access to files outside of the working
66+
directory.
67+
68+
The `fs.read` and `fs.write` entitlements take a path value (relative or
69+
absolute) to a directory on the filesystem. Alternatively, you can pass a
70+
wildcard (`*`) to allow Bake to access the entire filesystem.
71+
72+
### Example: fs.read
73+
74+
Given the following Bake configuration, Bake would need to access the parent
75+
directory, relative to the Bake file.
76+
77+
```hcl
78+
target "app" {
79+
context = "../src"
80+
}
81+
```
82+
83+
Assuming `docker buildx bake app` is executed in the same directory as the
84+
`docker-bake.hcl` file, you would need to explicitly allow Bake to read from
85+
the `../src` directory. In this case, the following invocations all work:
86+
87+
```console
88+
$ docker buildx bake --allow fs.read=* app
89+
$ docker buildx bake --allow fs.read=../ app
90+
$ docker buildx bake --allow fs.read=../src app
91+
```
92+
93+
### Example: fs.write
94+
95+
The following `docker-bake.hcl` file requires write access to the `/tmp`
96+
directory.
97+
98+
```hcl
99+
target "app" {
100+
output = "/tmp"
101+
}
102+
```
103+
104+
Assuming `docker buildx bake app` is executed outside of the `/tmp` directory,
105+
you would need to allow the `fs.write` entitlement, either by specifying the
106+
path or using a wildcard:
107+
108+
```console
109+
$ docker buildx bake --allow fs.write=/tmp app
110+
$ docker buildx bake --allow fs.write=* app
111+
```
112+
53113
### <a name="builder"></a> Override the configured builder instance (--builder)
54114

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

0 commit comments

Comments
 (0)