Use additional contexts
A context maps a name to an input:
Read more in the Docker Bake contexts documentation.
Use the default build context
For every generated target exceptbuild, BuildCharts adds a context named build that points to the generated build target:
build as an upstream stage:
target:build refers to the generated Bake target named build. BuildCharts requires exactly one build target in build.yml, so the context is stable and unambiguous.
Keep build for this automatic context. Do not define build under with.contexts or types.<type>.contexts.
Add a target dependency
Usewith.contexts when one target needs a named dependency that other targets do not.
docker target receives:
- The automatic
build = "target:build"context - The configured
publish = "target:publish"context
Share a dependency by type
Usetypes.<type>.contexts when every target of a type needs the same dependency.
Use image and local contexts
Contexts can also point to images or local paths.docker chart can consume the base image context:
nuget chart can copy from the git local context:
.git directory, bind mount it for the duration of the RUN step:
Context naming rules
Use context names that are valid HCL identifiers:- Start with a letter or
_ - Contain only letters, numbers, and
_ - Use non-empty values
with.contexts and types.<type>.contexts.