Interview Prep/Docker/Multi-stage builds, cache, tags and registries

How do you target a single stage while debugging a multi-stage build?

BeginnerScenarioMulti-stage builds, cache, tags and registries
Answer

Situation read → Need to inspect the build stage output.

What I'd do →

docker build --target build -t app:debug .
docker run --rm -it app:debug sh

Use docker buildx build --target test --progress=plain . to run only tests.

Why → BuildKit only builds stages the target depends on, which also saves time.

Interview tip → Name stages with AS for readability.

All Docker questions Roadmap: Docker & containers

More on Multi-stage builds, cache, tags and registries