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.
More on Multi-stage builds, cache, tags and registries
Show a multi-stage Dockerfile for a Java Spring Boot app and explain what you gain.BeginnerCI rebuilds from scratch every run and takes 12 minutes. How do you bring it down?IntermediateYou tag every build `myapp:latest`. A rollback is requested. What happens?BeginnerHow do you promote an image from dev to prod registry without rebuilding?IntermediateDisk on the build server keeps filling up with images.BeginnerWhen do you use `--no-cache` and when is it a smell?Beginner