Skip to content

Commit e540b7a

Browse files
authored
Merge pull request #3421 from aevesdocker/ENGDOCS-2992
docs: --load flag clarity
2 parents 3293a2e + 05c6753 commit e540b7a

File tree

2 files changed

+53
-4
lines changed

2 files changed

+53
-4
lines changed

commands/bake.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,8 +499,8 @@ func bakeCmd(dockerCli command.Cli, rootOpts *rootOptions) *cobra.Command {
499499
flags := cmd.Flags()
500500

501501
flags.StringArrayVarP(&options.files, "file", "f", []string{}, "Build definition file")
502-
flags.BoolVar(&options.exportLoad, "load", false, `Shorthand for "--set=*.output=type=docker"`)
503-
flags.BoolVar(&options.exportPush, "push", false, `Shorthand for "--set=*.output=type=registry"`)
502+
flags.BoolVar(&options.exportLoad, "load", false, `Shorthand for "--set=*.output=type=docker". Conditional.`)
503+
flags.BoolVar(&options.exportPush, "push", false, `Shorthand for "--set=*.output=type=registry". Conditional.`)
504504
flags.StringVar(&options.sbom, "sbom", "", `Shorthand for "--set=*.attest=type=sbom"`)
505505
flags.StringVar(&options.provenance, "provenance", "", `Shorthand for "--set=*.attest=type=provenance"`)
506506
flags.StringArrayVar(&options.overrides, "set", nil, `Override target value (e.g., "targetpattern.key=value")`)

docs/reference/buildx_bake.md

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ Build from a file
2222
| `-D`, `--debug` | `bool` | | Enable debug logging |
2323
| [`-f`](#file), [`--file`](#file) | `stringArray` | | Build definition file |
2424
| [`--list`](#list) | `string` | | List targets or variables |
25-
| `--load` | `bool` | | Shorthand for `--set=*.output=type=docker` |
25+
| [`--load`](#load) | `bool` | | Shorthand for `--set=*.output=type=docker`. Conditional. |
2626
| [`--metadata-file`](#metadata-file) | `string` | | Write build result metadata to a file |
2727
| [`--no-cache`](#no-cache) | `bool` | | Do not use cache when building the image |
2828
| [`--print`](#print) | `bool` | | Print the options without building |
2929
| [`--progress`](#progress) | `string` | `auto` | Set type of progress output (`auto`, `quiet`, `plain`, `tty`, `rawjson`). Use plain to show container output |
3030
| [`--provenance`](#provenance) | `string` | | Shorthand for `--set=*.attest=type=provenance` |
3131
| [`--pull`](#pull) | `bool` | | Always attempt to pull all referenced images |
32-
| `--push` | `bool` | | Shorthand for `--set=*.output=type=registry` |
32+
| [`--push`](#push) | `bool` | | Shorthand for `--set=*.output=type=registry`. Conditional. |
3333
| [`--sbom`](#sbom) | `string` | | Shorthand for `--set=*.attest=type=sbom` |
3434
| [`--set`](#set) | `stringArray` | | Override target value (e.g., `targetpattern.key=value`) |
3535

@@ -220,6 +220,47 @@ format. Alternatively, you can use a long-form CSV syntax and specify a
220220
$ docker buildx bake --list=type=targets,format=json
221221
```
222222

223+
### <a name="load"></a> Load images into Docker (--load)
224+
225+
The `--load` flag is a convenience shorthand for adding an image export of type
226+
`docker`:
227+
228+
```console
229+
--load ≈ --set=*.output=type=docker
230+
```
231+
232+
However, its behavior is conditional:
233+
234+
- If the build definition has no output defined, `--load` adds
235+
`type=docker`.
236+
- If the build definition’s outputs are `docker`, `image`, `registry`,
237+
`oci`, `--load` will add a `type=docker` export if one is not already present.
238+
- If the build definition contains `local` or `tar` outputs,
239+
`--load` does nothing. It will not override those outputs.
240+
241+
For example, with the following bake file:
242+
243+
```hcl
244+
target "default" {
245+
output = ["type=tar,dest=hi.tar"]
246+
}
247+
```
248+
249+
With `--load`:
250+
251+
```console
252+
$ docker buildx bake --load --print
253+
...
254+
"output": [
255+
{
256+
"dest": "hi.tar"
257+
"type": "tar",
258+
}
259+
]
260+
```
261+
262+
The `tar` output remains unchanged.
263+
223264
### <a name="metadata-file"></a> Write build results metadata to a file (--metadata-file)
224265

225266
Similar to [`buildx build --metadata-file`](buildx_build.md#metadata-file) but
@@ -339,6 +380,14 @@ Same as [`build --provenance`](buildx_build.md#provenance).
339380

340381
Same as `build --pull`.
341382

383+
### <a name="push"></a> Push images to a registry (--push)
384+
385+
The `--push` flag follows the same logic as `--load`:
386+
387+
- If no outputs are defined, it adds a `type=image,push=true` export.
388+
- For existing `image` outputs, it sets `push=true`.
389+
- If outputs are set to `local` or `tar`, it does not override them.
390+
342391
### <a name="sbom"></a> Create SBOM attestations (--sbom)
343392

344393
Same as [`build --sbom`](buildx_build.md#sbom).

0 commit comments

Comments
 (0)