---
source: https://iinventedlight.com/library/notes/docker-build-bake-overrides.md
title: "Docker Bake overrides: files, --set flags, and last-loaded precedence"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "Apache License 2.0 (Docker, Inc.); Apache License 2.0 (Docker, Inc.); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "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."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-26
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-26
as_of: 2026-11-26
confidence: medium
untested: "Not reproduced (2026-11-26). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-devops: docker-build-bake-overrides"
tags: [docker, bake, overrides, buildx, build]
client: Librarian
sources:
  - id: S1
    title: "Overriding configurations"
    publisher: Docker, Inc.
    url: https://docs.docker.com/build/bake/overrides/
    accessed: 2026-11-26
    license: "Apache License 2.0"
  - id: S2
    title: "Overriding configurations (source)"
    publisher: Docker, Inc.
    url: https://raw.githubusercontent.com/docker/docs/main/content/manuals/build/bake/overrides.md
    accessed: 2026-11-26
    license: "Apache License 2.0"
---
# 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

- [docker-buildx-bake](https://iinventedlight.com/library/notes/docker-buildx-bake/)
- [docker-buildx-build](https://iinventedlight.com/library/notes/docker-buildx-build/)
- [docker-build-variables](https://iinventedlight.com/library/notes/docker-build-variables/)

## Claims

- id: C1
  claim: When two files set the same target, the last loaded file wins.
  source: S1
  evidence: "In the case of overrides, the last one loaded takes precedence."

- id: C2
  claim: Bake loads named files in the order it finds them.
  source: S2
  evidence: "Bake will attempt to load all of the files in the order they are found."

- id: C3
  claim: Array literals are not accepted on --set tag assignments.
  source: S1
  evidence: "Array literal syntax such as --set app.tag=[a,b] is not supported."

## Sources

- [S1] Overriding configurations. Docker, Inc.. https://docs.docker.com/build/bake/overrides/ . License: Apache License 2.0. Accessed 2026-11-26.

- [S2] Overriding configurations (source). Docker, Inc.. https://raw.githubusercontent.com/docker/docs/main/content/manuals/build/bake/overrides.md . License: Apache License 2.0. Accessed 2026-11-26.

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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
