- Packages are re-downloaded from scratch on every build.
- Secrets can leak into image metadata despite workarounds.
- Builds are locked to the architecture of the machine used for building.
- Independent stages in multi-stage builds run sequentially instead of in parallel.
docker build uses under the hood. The ”[+] Building 12.3s” style status lines you see are BuildKit’s output.

- Smarter caching: BuildKit hashes file contents used by a layer (not timestamps), so cache hits are more reliable.
- Four modern features that directly address the four legacy problems:
- Cache mounts
- Secret mounts
- Multi-platform builds
- Parallel stage execution
For advanced BuildKit features (secrets, cache mounts, multi-platform builds, etc.) use
docker buildx build. For most simple builds docker build already uses BuildKit by default on modern Docker releases.- Cache mounts — avoid re-downloading packages
--mount syntax you must declare the modern Dockerfile frontend at the top of the Dockerfile:
# syntax=... directive tells BuildKit to use the newer frontend; without it the --mount syntax won’t be available.
First build downloads packages normally:
- Secret mounts — avoid leaking secrets into images
Never bake secrets into image layers or pass them as plain build args. Use BuildKit secret mounts so secrets are available only during the RUN step and are not written to layers or image metadata.
- Multi-platform builds — build for different architectures in one command
- Parallel stage execution — speed up independent multi-stage builds
- Dockerfile fundamentals remain the same: layers,
FROM,RUN,COPY,ENTRYPOINT, etc., still apply. - BuildKit is a faster, smarter engine that preserves the same Dockerfile semantics while adding powerful features.
- Use cache mounts for dependency-heavy steps, secret mounts to avoid leaking credentials, Buildx for multi-arch builds, and rely on BuildKit’s DAG analysis for parallelism.
- For everyday builds
docker buildis sufficient; for advanced workflows usedocker buildx build.