Docker · Containers in practice

What does BuildKit add over the classic Docker builder?

HardbuildkitbuildcachingUpdated Oct 2026
Quiz this track

Short answer

BuildKit builds a dependency graph, runs independent stages in parallel, supports cache mounts, secret mounts and multi-platform builds, and produces better cache reuse.

BuildKit is the modern build engine behind docker build and docker buildx. It converts the Dockerfile into a low-level build graph, so steps that do not depend on each other can run concurrently and only the needed outputs are transferred.

dockerfile
# syntax=docker/dockerfile:1.7
FROM node:20-alpine
WORKDIR /app
COPY package.json package-lock.json ./
RUN --mount=type=cache,target=/root/.npm npm ci
COPY . .
RUN npm run build
A cache mount keeps the npm cache across builds without baking it into a layer.

Capabilities

  • Parallel execution of independent build stages
  • Cache mounts for package managers and compilers
  • Secret and SSH mounts that do not persist in layers
  • Multi-platform builds through buildx and emulation or native builders
  • Inline and registry cache export for CI
  • SBOM and provenance attestations

BuildKit is stricter in places. Unused build arguments warn, some legacy Dockerfile behaviour differs, and the frontend version matters. Pin the syntax directive when you rely on a feature such as cache mounts.

A cache mount speeds up builds but can hide a stale dependency if the lockfile is not copied correctly. It does not replace pinning dependency versions.

Follow-ups you should expect

Interviewers use these to check whether the first answer was understanding or memorisation.

  1. 1How is a cache mount different from a layer cache?
  2. 2Why pin the syntax directive in a Dockerfile?
  3. 3How does BuildKit help multi-platform builds?
  4. 4What is the difference between docker build and docker buildx build?

Say it in the interview

BuildKit builds a dependency graph instead of executing instructions strictly one by one, so independent stages run in parallel and cache reuse is better. I use cache mounts for package managers, secret mounts for build credentials, and buildx for multi-platform images and remote cache. I pin the syntax directive when I depend on those features, since behaviour can vary by frontend version.

Use this as a model, not a script. Saying it in your own words is what makes it survive follow-up pressure.

Related questions

Reading is step one

Now say it out loud.

Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live Docker mock interview and get scored feedback on depth, clarity and confidence.