Docker Builds Always Start From Scratch
On ephemeral CI runners, every docker build downloads all dependencies again because each runner starts empty. What makes layer caching work across runs?
docker build
Choose one answer
Build with --no-cache=false, which tells Docker to keep layers between runs.
--no-cache=false
Use docker save at the end of the job and docker load at the start.
docker save
docker load
Use buildx with --cache-from and --cache-to (registry or the CI cache).
--cache-from
--cache-to
Add RUN --mount=type=cache to every step, which stores layers in the image.
RUN --mount=type=cache