Docker "buildx bake" Failed in CI
docker buildx bake failed while reading or executing the bake definition. The HCL/JSON file is invalid, a named target or variable is undefined, or a target points at a Dockerfile/context that does not resolve.
What this error means
A docker buildx bake <target> exits non-zero with a parse error, target <name> not found, an undefined-variable error, or a downstream build error from one of the baked targets.
ERROR: failed to load bake file: docker-bake.hcl:12,1-7: Unsupported argument;
# or:
ERROR: no such target: relase (typo of "release")Common causes
Invalid bake HCL/JSON
A syntax error, an unsupported argument, or a malformed block in docker-bake.hcl/.json fails to load before any target runs.
Target or variable not defined
Invoking a target name that is not in the file (often a typo), or referencing an undefined variable, errors out.
A target references an unresolved Dockerfile/context
A target whose dockerfile/context path is wrong fails when bake tries to build it.
How to fix it
Print the resolved bake definition
Use --print to validate the file and see the effective targets before building.
docker buildx bake --print
docker buildx bake releaseFix the target name, variables, and paths
Match the invoked target to a defined one and give defaults to variables.
# docker-bake.hcl
variable "TAG" { default = "1.4.2" }
target "release" {
context = "."
dockerfile = "Dockerfile"
tags = ["ghcr.io/myorg/api:${TAG}"]
}How to prevent it
- Validate bake files with
--printin CI before building. - Default bake variables so missing inputs do not error.
- Keep target names and Dockerfile/context paths in sync with the file.