← All notes

Docker Bake overrides: files, --set flags, and last-loaded precedence

Answer: Bake can load build definitions from files, and you can override attributes for a given environment or target with extra files, --set, variables, or environment values.

File overrides and load order

You can use the --file or -f flag to specify which files to load.

Bake tries to load all of those files in the order they are found.

When more than one file defines the same target, attributes are merged or overridden.

In the case of overrides, the last one loaded takes precedence.

You can create a file that defines configurations for a specific environment, and load it only when building for that environment.

The docs show an override.hcl file that sets the TAG variable to bar.

This helps when you want to separate configurations into different files.

--set keys and arrays

For array fields such as tag, repeat the --set flag to provide multiple values, or use += when you want to append without replacing.

An empty assignment such as --set app.tag= clears the array, and assignments after that add values to the cleared array.

A bracket list such as --set app.tag=[a,b] is not supported.

Selectors on the command line use singular key names (arg, secret, tag), while attributes inside a Bake file keep the plural forms (args, tags).

Older plural spellings of those override keys still work as aliases.

context is not an alias of contexts: the first names the main build context, and the second form with a name sets one additional named context.

The secrets alias applies only to the secret list override, and secrets.<id> is invalid.

A pattern can match more than one target.

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Docker, Inc., Overriding configurations; Docker, Inc., Overriding configurations (source). Apache-2.0 (https://raw.githubusercontent.com/docker/docs/main/LICENSE). Copyright Docker, Inc. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Docker, Inc., Overriding configurations; Docker, Inc., Overriding configurations (source). Apache-2.0 (https://raw.githubusercontent.com/docker/docs/main/LICENSE). Copyright Docker, Inc.

Cite this

Permanent ID: iil:note:h7qeemps

iinventedlight. 2026. "Docker Bake overrides: files, --set flags, and last-loaded precedence." iinventedlight Library, iil:note:h7qeemps, version of 2026-11-26. https://iinventedlight.com/library/notes/docker-build-bake-overrides/. License: CC-BY-4.0.

@misc{iil_note_h7qeemps,
  author = {{iinventedlight}},
  title = {{Docker Bake overrides: files, --set flags, and last-loaded precedence}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-26},
  url = {https://iinventedlight.com/library/notes/docker-build-bake-overrides/},
  note = {Permanent ID iil:note:h7qeemps. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

Extra files beside this note

These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/docker-build-bake-overrides.md.