TOPIC 19/1916 MINNOT STARTED

Docker in a pipeline: build the image, run the tests inside it and keep the report

Build the test image in a pipeline, run the tests inside it, reuse cached layers, keep secrets out of the image and save the report folder.

L1–L4 are part of the Pro pass

L0 Explain simply

Analogy: packing a suitcase in layers. Things that rarely change go at the bottom. Things that change every trip go on top. Next time you pack only the top again. The house key does not go in the suitcase. You carry the key in your pocket for the journey, and you bring the receipts home in a folder.

The bottom layers are the cache. The top layer is the test code. The key in the pocket is a runtime secret. The receipts are the report folder.

Leo, a developer at Daily List, a to-do list app, packs the test image for the pipeline. Mei needs the report after the container stops.

What it is: This topic is Docker inside (CI), where the shared build makes an image and runs the tests in it. The reuses unchanged build steps. A report folder bind mount shares a host folder so the report outlives the container. A build secret mount exists only during the build, not when the container starts. GitHub Actions without Docker is the neighbour, and it uses the runner's own system.

Why it matters: Daily List tests should see the same (OS) and the same packages on every run. The cache keeps rebuilds shorter. The report mount keeps the JUnit XML (Extensible Markup Language) after the container exits. A test token must not be baked into an image that might be pushed. BuildKit secrets do not solve a key the tests need at run time.

PLAIN WORDS · 6 in this section
runtime
the time when a program is actually running
reuses
uses again
outlives
lasts longer than
github
a web site that hosts code and runs checks
junit
a file format for test results
extensible
able to be added to later

PICTURE IT

The picture is the one the lesson above opens with. The table below shows how each part of it matches the software.

THE REAL JOB Packing a suitcase in layers and leaving the house key at home.

  1. Bottom
  2. Top
  3. Key
Suitcase

HOW THE PICTURE MAPS

How each part of the picture matches the software
In the pictureIn the software
Shoes at the bottomSteps that change least
Clothes on topThe test code
The key left at homeA secret kept out of the image
A bag you carry outThe shared report folder

WHERE THIS PICTURE STOPS

  • A suitcase has a size limit, but an image can grow large.
  • Packing the top again is quick, yet one change low down means packing again above it.
  • The bag carried out is yours alone, while a shared folder can write to the host.

HOOK

Shoes below, clothes above, key at home.

TELL A FRIEND

Pack the stable things first and keep the key home.

OFTEN MIXED UP WITH Docker part 2: write a Dockerfile and build your own test image. That topic writes a Dockerfile for a test image. This one builds and runs it in a pipeline, with cache, secrets and a saved report.

PRACTISE AND KEEP

Sources for this topic — 3 sources
  1. Market practice

    Build cache invalidation (Docker documentation) ↗ — Docker · Docker docs on the build cache: steps are checked in order, and after one miss every later step is built again, so put steps that change least first

    The Docker pages on the build cache: steps are checked in order, and once one step misses the cache every later step is built again. Docker advises putting steps that change less often first, such as copying dependency lists before the source. · Checked 2026-10-31

    Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.

  2. Market practice

    Build secrets (Docker documentation) ↗ — Docker · Docker docs on build secrets: build arguments and environment variables are not suitable for secrets, and a secret mount keeps the secret out of the image

    The Docker pages on build secrets: build arguments and environment variables are not suitable for secrets. A secret mount makes a secret available to one build step without keeping it in the image or the cache. · Checked 2026-10-31

    Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.

  3. Market practice

    Bind mounts (Docker documentation) ↗ — Docker · Docker docs on bind mounts: the volume option takes a host path, then a container path, so files the container writes appear on the host

    The Docker pages on bind mounts: the volume option takes a host path, then a container path. A missing host folder is created for you with that option. A read-only flag can be added, and bind mounts can write to host files by default. · Checked 2026-10-31

    Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.

Deepest material on this page: L4 — Standards & sources. Where a topic stops short of implementation depth, that is a deliberate coverage decision, not an oversight — see coverage.