Checkpoint Lab — Build Contexts, .dockerignore, Remote Contexts, Named Contexts, and Deterministic Build Inputs
The checkpoint creates an evidence-backed build-input dossier: a minimized local context and a named/pinned-input design are built, their input identities and transfer evidence are recorded, unrelated files are changed deliberately, and the learner proves those unrelated files cannot influence the intended result.
Learning objectives
- Produce two bounded build-input designs for the same small application: minimized default context and explicit named/pinned inputs.
- Predict which files can influence each build, then verify the predictions from progress and output evidence.
- Record local source hashes or Git commit identity, ignore rules, named-context configuration, builder/frontend versions, and final image identity.
- Modify unrelated ignored data and prove it does not enter the intended build dependency set.
- Clean only chapter-owned images/containers/files and preserve the evidence packet for review.
1. Checkpoint mission and evidence contract
Build the same tiny application through two bounded input designs: a minimized default local context and a default context plus an explicit named documentation context. Record every input identity, builder/frontend baseline, BuildKit progress, image identity, and runtime output. Then modify an ignored unrelated file and prove the intended build dependency set does not change.
2. Preflight
mkdir -p ch08-checkpoint/{app,docs,noise,evidence}
cd ch08-checkpoint
docker context show | tee evidence/00-context.txt
docker version | tee evidence/01-version.txt
docker buildx version | tee evidence/02-buildx.txt
docker buildx inspect --bootstrap | tee evidence/03-builder.txt
Record limitations if a Buildx feature is unavailable. The mandatory path uses only local synthetic sources; the remote Git checksum form is documented as an optional compatibility exercise.
3. Create source-controlled inputs and a local immutable revision
printf 'application-v1\n' > app/message.txt
printf 'documentation-v1\n' > docs/readme.md
printf 'unrelated-v1\n' > noise/cache.tmp
printf 'FAKE_CREDENTIAL=not-a-secret\n' > .env
git init
git add app docs noise .env
git -c user.name='DevOps Academy' -c user.email='academy@example.invalid' commit -m 'checkpoint inputs'
SRC_SHA=$(git rev-parse HEAD)
printf 'source_commit=%s\n' "$SRC_SHA" | tee evidence/04-source-commit.txt
sha256sum app/message.txt docs/readme.md | tee evidence/05-input-hashes.txt
4. Design A: minimized default context
# .dockerignore
.git
.env
noise
evidence
docs
# local.Dockerfile
# syntax=docker/dockerfile:1
FROM busybox:1.37.0
WORKDIR /app
COPY app/message.txt ./message.txt
CMD ["cat", "/app/message.txt"]
docker buildx build --progress=plain --load \
-f local.Dockerfile \
--label devops-academy.lab=ch08-checkpoint \
-t devops-academy-ch08-checkpoint:local . \
2>&1 | tee evidence/06-local-build.txt
docker image inspect devops-academy-ch08-checkpoint:local \
--format 'ImageID={{.Id}} RepoDigests={{json .RepoDigests}}' \
| tee evidence/07-local-image.txt
docker run --rm devops-academy-ch08-checkpoint:local \
| tee evidence/08-local-runtime.txt
5. Design B: explicit named documentation context
# named.Dockerfile
# syntax=docker/dockerfile:1
FROM busybox:1.37.0
WORKDIR /app
COPY app/message.txt ./message.txt
COPY --from=docs /readme.md ./docs/readme.md
CMD ["sh", "-c", "cat /app/message.txt; cat /app/docs/readme.md"]
docker buildx build --progress=plain --load \
-f named.Dockerfile \
--build-context docs=./docs \
--label devops-academy.lab=ch08-checkpoint \
-t devops-academy-ch08-checkpoint:named . \
2>&1 | tee evidence/09-named-build.txt
docker image inspect devops-academy-ch08-checkpoint:named \
--format 'ImageID={{.Id}} RepoDigests={{json .RepoDigests}}' \
| tee evidence/10-named-image.txt
docker run --rm devops-academy-ch08-checkpoint:named \
| tee evidence/11-named-runtime.txt
Design B intentionally has a different payload because it includes documentation. The checkpoint is not trying to force identical image IDs; it is proving explicit dependency boundaries and recorded source identity.
6. Prediction gate before changing unrelated data
Write down two predictions before the next command:
-
Changing
noise/cache.tmpshould not alter the default context seen by either build becausenoiseis ignored. -
Changing
docs/readme.mdshould not affect Design A, but should affect Design B becausedocsis an explicit named input.
8. Prove the named input is a real dependency
printf 'documentation-v2\n' > docs/readme.md
sha256sum docs/readme.md | tee evidence/15-docs-v2-hash.txt
docker buildx build --progress=plain --load \
-f named.Dockerfile --build-context docs=./docs \
-t devops-academy-ch08-checkpoint:named2 . \
2>&1 | tee evidence/16-named-after-doc-change.txt
docker run --rm devops-academy-ch08-checkpoint:named2 \
| tee evidence/17-named2-runtime.txt
Now the output should contain documentation-v2. That
contrast proves why named contexts improve causal reasoning: one
independently identified source changed and only the build that
consumes it changes behavior.
9. Optional remote Git checksum exercise
If network access and compatible tooling are available, choose a public disposable/test repository or your own reviewed source, record the expected commit, and use the structured Git URL-query form:
# Example shape only — substitute a reviewed repository/ref/commit.
docker buildx build \
'https://github.com/ORG/REPO.git?tag=vX.Y.Z&subdir=docker&checksum=EXPECTED_COMMIT' \
--progress=plain
If the checksum does not match the selected ref, the correct result is a failed build. Preserve that mismatch evidence. Do not weaken the check to make the build pass.
10. Evidence packet review
Your evidence/ directory should answer:
- Which Docker context, Engine/CLI, Buildx and builder handled the builds?
- What source-control commit and file hashes identify the local inputs?
- Which root/Dockerfile-specific ignore rules were in force?
- What did plain progress report for default and named contexts?
-
Which source names/paths were supplied through
--build-context? - What local image identities resulted?
- Which unrelated change was proven irrelevant?
- Which named-source change was proven relevant?
- What remote Git checksum capability/limitations applied?
11. Exact cleanup
docker image rm \
devops-academy-ch08-checkpoint:local \
devops-academy-ch08-checkpoint:local2 \
devops-academy-ch08-checkpoint:named \
devops-academy-ch08-checkpoint:named2
docker image ls --filter label=devops-academy.lab=ch08-checkpoint
date -u +%Y-%m-%dT%H:%M:%SZ | tee evidence/18-finished-at.txt
Do not use broad prune. Keep the evidence directory and local Git metadata if you want the checkpoint to remain independently reviewable.
12. Operational review and Chapter 09 handoff
Chapter 08 established the build input boundary: default context, ignore processing, Dockerfile-specific precedence, remote source identity, and named contexts are all distinct build state. You can now prove which source bytes were eligible to affect an image rather than merely trusting the directory name or Git branch.
Chapter 09 moves inside the builder itself: BuildKit and buildx Architecture, Builders, Frontends, Progress, Outputs, and Modern Build Workflows. The context evidence created here becomes the input side of that deeper build-execution model.
Knowledge check
Which checkpoint change should be irrelevant to both builds?
The change under ignored noise/.
Which change should affect only the named-context design?
The change to docs/readme.md, because Design B
consumes docs explicitly while Design A excludes
it.
Why does the checkpoint not require identical local image IDs for every environment?
Builder/frontend/output metadata can vary. The core requirement is causal evidence connecting the declared inputs to the resulting payload and recorded identity under the actual environment.
What should happen if a remote Git tag does not match the expected checksum?
The build should fail; the mismatch is evidence of source drift and should not be bypassed silently.
What new question does Chapter 09 answer?
How Buildx, builder instances, BuildKit workers/frontends, cache, progress, and exporters execute the bounded inputs established here.
Official references and version notes
-
Build context
— authoritative behavior for local directories, Git repositories,
tarballs, stdin/empty contexts,
.dockerignore, Dockerfile-specific ignore files, Git URL queries/checksums, and named contexts. -
docker buildx build—--build-context, progress, outputs, metadata, and accepted named-context source types. -
Optimize cache usage
— why a small context improves transfer and cache behavior and how
.dockerignorereduces unnecessary input. -
Dockerfile reference
— how
COPY,ADD, andRUN --mountconsume build inputs. - Build best practices — source-control, cache, image, and reproducibility guidance.
- Docker Engine 29 release notes — current Engine baseline and fixes.
- Buildx releases — current Buildx feature/compatibility history.
- BuildKit releases — current BuildKit and built-in Dockerfile frontend releases.
Version-sensitive statements were rechecked against primary
documentation on 2026-09-21. Docker Engine 29.8.1
is the current Engine 29 patch release at this checkpoint; Buildx
0.37.1 and BuildKit 0.33.0 are current upstream baselines observed
in the current Docker packaging/release stream, and BuildKit
0.33.0 includes the built-in Dockerfile frontend 1.27.0. Docker
documents structured Git URL queries with
checksum/commit as requiring Buildx
0.28.0+, Dockerfile 1.18.0+, and Docker Desktop 4.46.0+ where
Desktop is used. Labs therefore record the learner's actual
builder/frontend state and include a local simulation path instead
of assuming remote Git-query support or network access.
Keep the academy open
Support free, practical DevOps education.
Every lesson is designed to remain readable in a browser, downloadable from GitHub, and usable without a paid learning platform. Contributions help expand and maintain the curriculum.
0x716c4Ab160C4B66F31a28AE2448BfF68fc3a2ef0
Send only Ethereum/ERC-20 compatible assets to this
address.