$linuxjunkies
>

BuildKit

also: moby/buildkit, buildx

BuildKit is a modern, container image builder for Docker that replaces the legacy builder with improved performance, caching, and support for advanced features like multi-stage builds and secrets handling.

BuildKit is Docker's next-generation build engine that processes Dockerfile instructions more efficiently than the classic builder. It uses a DAG (directed acyclic graph) to represent build steps, enabling parallel execution of independent layers and smarter caching strategies.

Key advantages include support for build secrets (preventing credentials from leaking into layers), improved layer caching that doesn't depend on build context ordering, and native support for BuildKit-specific syntax extensions. For example, you can use RUN --mount=type=secret to safely inject secrets during builds without persisting them in the image.

Enable BuildKit with the environment variable DOCKER_BUILDKIT=1 before running docker build. It's also the default builder in Docker Desktop and newer Docker Engine versions.

Related terms