docs: add docs for bake network mode config

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
Tonis Tiigi 2024-09-03 18:20:11 -07:00
parent fa1d19bb1e
commit f0f8876902
No known key found for this signature in database
GPG Key ID: AFA9DE5F8AB7AF39
1 changed files with 21 additions and 0 deletions

View File

@ -768,6 +768,27 @@ target "app" {
} }
``` ```
### `target.network`
Specify the network mode for the whole build request. This will override the default network mode
for all the `RUN` instructions in the Dockerfile. Accepted values are `default`, `host`, and `none`.
Usually, a better approach to set the network mode for your build steps is to instead use `RUN --network=<value>`
in your Dockerfile. This way, you can set the network mode for individual build steps and everyone building
the Dockerfile gets consistent behavior without needing to pass additional flags to the build command.
If you set network mode to `host` in your Bake file, you must also grant `network.host` entitlement when
invoking the `bake` command. This is because `host` network mode requires elevated privileges and can be a security risk.
You can pass `--allow=network.host` to the `docker buildx bake` command to grant the entitlement, or you can
confirm the entitlement when prompted if you are using an interactive terminal.
```hcl
target "app" {
# make sure this build does not access internet
network = "none"
}
```
### `target.no-cache-filter` ### `target.no-cache-filter`
Don't use build cache for the specified stages. Don't use build cache for the specified stages.