When do you use `--no-cache` and when is it a smell?
BeginnerScenarioMulti-stage builds, cache, tags and registries
Answer
Situation read → It forces every layer to be rebuilt.
What I'd do → Use it occasionally (weekly scheduled build) to pull in OS security updates when you do not pin packages, or when debugging cache poisoning. As a default in CI it is a smell: it hides poor layer ordering and slows everything.
Why → Better: bump a build ARG such as CACHE_BUST at a chosen layer, or use --pull to refresh the base.
Interview tip → --pull and --no-cache solve different problems.
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.BeginnerExplain a build where `COPY` always misses the cache even though code did not change.Intermediate